PHP mail: Multiple recipients?

Separate the addresses with commas.

$to=array();
while($row = mysql_fetch_array($result)) {
    array_push($to, $row['address']);
}

...

mail(implode(',', $to), $submit, $message, $headers);

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.


I just tested the codes you presented and before using them, people need to know that using this way (multiple addresses in 'to' field), every single person in that email can see all the destinatars.

Also, if you're using Bcc, they'll also know the first person in the list.

Be aware! :)

Tags:

Php

Email