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 = "me@yourname.com"; $contactname = "Administrator"; $contactemail = "me@yourname.com"; $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="me@yourname.com"; $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 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 = 'me@example.com' . ', '; // note the comma $to .= 'you@example.com'; mail($to, $subject, $message, $headers); Quote Link to comment 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: eavesdropper@example.com'); mail($recipient, $subject, $message, 'cc: eavesdropper@example.com'); 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 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" <jim@jim.com> Not: Jim <jim@jim.com> 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\" <jim@jim.com>, \"bob\" <bob@bob.com>"; All headers need \r\n at the end or it may not be picked up by the mail server. CC should work: $headers = 'Cc: mail@example.com' . "\r\n"; Quote Link to comment Share on other sites More sharing options...
Lukeidiot Posted April 1, 2010 Share Posted April 1, 2010 Or just use this... <?php $to = "Email1@gmail.com, Email2@gmail.com, Email3@gmail.com"; $subject = "Subject here"; $body = "Msg here"; mail($to,$subject,$body); ?> Quote Link to comment 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(Email3@gmail.com). What should i try now? Quote Link to comment 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.