Forum Moderators: coopster
I want to send an email to multiple recipients. As I understand it:
It is possible to send an email to multiple recipients with a single call to the mail() function. Here is an example. All you need to do is modify
the recipient variable as follows:
$to = "johndoe@fakedomain.com, somebodyelse@fakedomain.com";
In other words, simply separate each required recipient by a comma.
Seems simple enough. I guess that the above code is equivalent to some other syntax that I have seen out there for sending
email to multiple recipients:
$to = "mary@example.com" . ", " ; // note the comma
$to .= "kelly@example.com";
Am I right in this?
Then there is some other syntax that I have seen for sending email to multiple recipiants:
The part of the code below that I am referring to is the part with Cc and Bcc. Am I right in saying that this code will send emails to:
mary@example.com
kelly@example.com
birthdayarchive@example.com
birthdaycheck@example.com
With birthdaycheck@example.com being sent blind. The other recipiants do not know that this message has been sent to this email address?
<?php
/* recipients */
$to = "mary@example.com" . ", " ; // note the comma
$to .= "kelly@example.com";
/* subject */
$subject = "Birthday Reminders for August";
/* message */
$message = 'jhguguguygj';
/* headers */
$headers .= "To: Mary <mary@example.com>, Kelly <kelly@example.com>\r\n";
$headers .= "From: Birthday Reminder <birthday@example.com>\r\n";
$headers .= "Cc: birthdayarchive@example.com\r\n";
$headers .= "Bcc: birthdaycheck@example.com\r\n";
/* and now mail it */
mail($to, $subject, $message, $headers);
?>
In short - are the 3 coding methodologies for sending email to multiple recipiants that I have listed here all valid? Many thanks.