esport Posted March 16, 2007 Share Posted March 16, 2007 Hi Guys, I am wondering how do i send mail to mulitple recipients using the mail finction. Here is what i have so far: $myname = "Action Drafting - Contact Us"; $myemail = "[email protected]"; $contactname = "Administrator"; $contactemail = "[email protected]"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: ".$myname." <".$myemail.">\r\n"; $headers .= "To: ".$contactname." <".$contactemail.">\r\n"; $headers .= "Reply-To: ".$myname." <$myreplyemail>\r\n"; $headers .= "X-Priority: 1\r\n"; $headers .= "X-MSMail-Priority: High\r\n"; $headers .= "X-Mailer: Just My Server"; $toText="[email protected]"; $subjectText="Action Drafting Contact Us"; $msgText = "dadadadada"; mail($toText, $subjectText, $msgText, $headers); Do i have to make an array of emails then loop through or can i just add them to the headers and $toText??? Thanks Daniel Quote Link to comment https://forums.phpfreaks.com/topic/42928-mail-function-to-send-to-multiple-recipients/ Share on other sites More sharing options...
peeps Posted March 16, 2007 Share Posted March 16, 2007 Multiple recipients is possible. All you have to do is concatenate each email address with a comma and I think a space. $to = '[email protected]' . ', '; // note the comma $to .= '[email protected]'; mail($to, $subject, $message, $headers); Quote Link to comment https://forums.phpfreaks.com/topic/42928-mail-function-to-send-to-multiple-recipients/#findComment-208517 Share on other sites More sharing options...
deepson2 Posted April 1, 2010 Share Posted April 1, 2010 I have tried the above solution but its not working. Tried this also mail($recipient, $subject, $message, 'CC: [email protected]'); mail($recipient, $subject, $message, 'cc: [email protected]'); How can i get CC using php mail function? I don't want to use header because header is not working for me(And i have tried it already) Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/42928-mail-function-to-send-to-multiple-recipients/#findComment-1035165 Share on other sites More sharing options...
the182guy Posted April 1, 2010 Share Posted April 1, 2010 Put quotes around each name in the $to variable so the content of $to looks like "Jim" <[email protected]> Not: Jim <[email protected]> The email may not send if you don't do that. Multiple emails will work but be sure to include the name and seperate by comma like: $to = "\"Jim\" <[email protected]>, \"bob\" <[email protected]>"; All headers need \r\n at the end or it may not be picked up by the mail server. CC should work: $headers = 'Cc: [email protected]' . "\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/42928-mail-function-to-send-to-multiple-recipients/#findComment-1035173 Share on other sites More sharing options...
Lukeidiot Posted April 1, 2010 Share Posted April 1, 2010 Or just use this... <?php $to = "[email protected], [email protected], [email protected]"; $subject = "Subject here"; $body = "Msg here"; mail($to,$subject,$body); ?> Quote Link to comment https://forums.phpfreaks.com/topic/42928-mail-function-to-send-to-multiple-recipients/#findComment-1035174 Share on other sites More sharing options...
deepson2 Posted April 1, 2010 Share Posted April 1, 2010 Thanks for your reply Lukeidiot, If we consider the exact code yours I am getting mail for the last recipient only([email protected]). What should i try now? Quote Link to comment https://forums.phpfreaks.com/topic/42928-mail-function-to-send-to-multiple-recipients/#findComment-1035177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.