PHP Mail: Multiple Recipients

PHP mail: Multiple recipients?

while($row = mysql_fetch_array($result))
{
$addresses[] = $row['address'];
}
$to = implode(", ", $addresses);

As specified on the mail() manual page, the "to" parameter of the function can take a comma-separated list of addresses.

PHP form send email to multiple recipients

This will work:

$email_to = "jhewitt@amleo.com,some@other.com,yet@another.net";

Sending mail to multiple recipients

You can put multiple email addresses into the to field by simply adding a comma between them inside the parameter string like this:

mail("email1@mailserver.com, email2@mailserver.com", // rest of your code

Edit: Per comments below.

you can hide the multiple email addresses by using the additional headers param in the mail() function as per the docs on it:

// Additional 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";

This is the fourth param in the mail() arguments passed:

mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

CakeEmail - Set multiple recipients

If you need to send email to multiple recipients, you need to specify them as array.

            $email->config('smtp')
->to( array('first@email.com', 'second@email.com'));

From the Docs

'to': Email or array of destination.



Related Topics



Leave a reply



Submit