I am able to send email to one email id by defining the id in the mailer, but i am not able to understand how to send to multiple recepients when an user types "mssage and email id's" in a form. Ex - I am showing a form with two text areas - one for email id's and one for custom message. So when they click send, i want to take the email id's from that text area and send that message to those ids. I am yet to figure out how to comma/space seperate the emailds but will try it in google search.
thanks
The documentation of the to parameter for the mail() function states:
Receiver, or receivers of the mail.
The formatting of this string must comply with » RFC 2822. Some examples are:
* [email protected]
* [email protected], [email protected]
* User <[email protected]>
* User <[email protected]>, Another User <[email protected]>
http://php.net/manual/en/function.mail.php
Update:
I've come across this great tutorial on sending mail with PHP: http://articles.sitepoint.com/article/advanced-email-php
It's far easier to use something like PHPMailer (free, easy to install, easy to use) if you have to do anything even "moderately" complicated, like multiple recipients for an email. It'll hide all the ugly details for you behind a nice interface. Instead of worrying about header syntaxes and whatnot, you just do something like:
$mail = new PHPMailer();
$mail->AddAddress('[email protected]');
$mail->AddAddress('[email protected]');
etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With