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
Redirect After Login on Wordpress
Getting Last Month's Date in PHP
How to Get the Subversion Revision Number in PHP
Deleting a File After User Download It
Setting Up Laravel on a MAC PHP Artisan Migrate Error: No Such File or Directory
How to Compress/Decompress a Long Query String in PHP
How to Remove Part of a String in PHP
Ip Address Storing in MySQL Database Using PHP
Insert Current Date in Datetime Format MySQL
Enabling Postgresql Support in PHP on MAC Os X
Why Do I Have to Run "Composer Dump-Autoload" Command to Make Migrations Work in Laravel
Access Post Values in Symfony2 Request Object
What Is an .Inc and Why Use It
Phpexcel Auto Size Column Width
What Is Better in a Foreach Loop... Using the & Symbol or Reassigning Based on Key