PHP - multiple email addresses
Here is my php so far
$headers = "From: webinquiries@someplace.com\n";
$headers .= "Reply-To: sales@someplace.com\n";
$headers .= 'Bcc: someone@someplace.com' . "\r\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/plain; charset=ISO-8859-1\n";
mail($to, $subject, $body, $headers);
how do i add three 开发者_JS百科more email addresses to this list
You can pass a string with comma-separated e-mail addresses, or any other string that complies with RFC 2822.
Please read the mail function documentation in the PHP manual.
Create an array of email addresses, loop through each item in the array and call the mail()
function. Or submit a comma separated list like so User <user@example.com>, Another User <anotheruser@example.com>
.
If your emailing 'needs' require sending an extensive amount of emails, you might want to look into some third party libraries, as the mail
function is very 'delicate'.
Use something like Swiftmailer or PHPMailer - they eliminate the hard work in creating MIME-based emails, and allow any number of To/CC/BCC addresses in any combination.
精彩评论