I have a php form that a client needs to get the emails to 3 or 4 people. If in the form is $mailto = 'rchichester@gmail.com' ; Code (markup): can I add more addresses to this string, and do I need to add the single quotes around each one or around the lot of them?
If you want the emails to be different, you can create new vars, $to and $to2 with $body and $body2 If you want the same email, all To not CC, or BCC Then simply add another var $mailto = 'email@email.com' . "\r\n". $mailto = 'email2@email.com' . "\r\n". $mailto = 'email3@email.com'; I always suggest testing things like this, before giving it to the boss man.
Yes, the emails will all be the same just to 3 different people. I'll give that a try. Thanks! Now I have to wait for the 2 other emails to be set up. Why can't everyone just use Outlook...
Instead, I would probably simply put the email addresses into an array, and then loop through the array, calling mail() once for every email address. There are several ways to do this, though...
I'd strongly recommend using multiple addresses in either the To, Bcc or Cc fields rather than calling the mail() function several times. There's absolutely no point in calling mail() for every single email address if the message is going to be the same, just put all the recipient addresses in whichever field suits you best (e.g. Bcc if you don't want anyone to know who else the email has been sent to) and your mail server will transform that into the right number of individual messages. Don't do something in PHP if the mail server can do it for you (and probably a lot faster too).