Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending mail without $to

Status
Not open for further replies.

alsaffar

Programmer
Oct 25, 2001
165
KW
Hi there :)

How I can send mail via "mail" command without putting any email address in the "$to" field,

mail($to, $subject, $message, $headers);

because I want to send an email to multiple customers via "Bcc" field. I tried to leave the $to field empty or only ' ' (i.e. space) but none of them worked!

Please HelP ;)

Ali
 
No, you have to have a valid email in the "To:" field.

Instead of using the "BCC:" field, why not loop through your list of addresses that would be in the "BCC:" field, and use them individually in the "To:" field? ______________________________________________________________________
TANSTAAFL!
 
Is this method "sending individually" efficient for sending an email to more than 1000 customers?
 
efficient would be dividing the customers into groups of the same target host (hotmail, yahoo) and sending it as one mail while all the customers are, as you want, in the bcc field and maybe yours (local) in the to field, this way your mail server makes only one connection to the target host and delivers all the mail at once
 
One other way would be to use popen to print to sendmail yourself. An example:
<?php
$mail = popen(&quot;sendmail -t -i&quot;, &quot;w&quot;);
fwrite($mail, &quot;Subject: $subject\nBcc: $emails\nFrom: \&quot;The admin\&quot; <admin@yoursite.com>\n\n$message\n.\n&quot;);
pclose($mail);
?>
It's very important that the last three characters are \n.\n, otherwise, sendmail won't send the mail. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top