Jump to content

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

  • 3 years later...

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.