Jump to content

mail function to send to multiple recipients


esport

Recommended Posts

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

  • 3 years later...

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.

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";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.