PHP mailer URL

Possible duplicate:
PHPMailer AddAddress ()

Here is my code.

 require ('class.phpmailer.php');
 $ mail = new PHPMailer ();

 $ email = 'email1@test.com, email2@test.com, email3@test.com';

     $ sendmail = "$ email";

     $ mail-> AddAddress ($ sendmail, "Subject");
     $ mail-> Subject = "Subject"; 
     $ mail-> Body = $ content;      

     if (! $ mail-> Send ()) {# sending mail failed
         $ msg = "Unknown Error has Occured. Please try again Later.";
     }
     else {
         $ msg = "Your Message has been sent. We'll keep in touch with you soon.";
     }   
 }

Problem
if the value of $ email is only 1. It will send. But several do not send. What should I do for this. I know that in the mail function you need to separate several letters with a comma. But does not work in phpmailer.

+62
php phpmailer
Jun 30 '10 at 13:02
source share
1 answer

You need to call the AddAddress method once for each recipient. For example:

 $mail->AddAddress('person1@domain.com', 'Person One'); $mail->AddAddress('person2@domain.com', 'Person Two'); // .. 

Better yet, add them as Carbon Copy recipients.

 $mail->AddCC('person1@domain.com', 'Person One'); $mail->AddCC('person2@domain.com', 'Person Two'); // .. 

To make everything simple, you must skip the array to do this.

 $recipients = array( 'person1@domain.com' => 'Person One', 'person2@domain.com' => 'Person Two', // .. ); foreach($recipients as $email => $name) { $mail->AddCC($email, $name); } 
+194
Jun 30 '10 at 13:10
source share



All Articles