php - unable to send mail to multiple person in phpmailer -


i trying send mail multiple users using phpmailer.

what doing that:

a) firstly entering email ids seperated comma, let user enters : test@test.com,test1@test.com

b) explode them array:

$email_list = $_post['emailid']; $email_array = explode(',',$email_list); 

c) array of email

array('0'=>'test@test.com','1'=>'test1@test.com') 

d) sending mail using phpmailer using foreach loop follow :

foreach($email_array $email_array )             {                 $email = $email_array;                 //die;                 include('notification/class.phpmailer.php');              $subject = $_post['subject'];             $body = $_post['content'];              $smtphost = get_option('smtphostlord');             $smtpportlord = get_option('smtpportlord');             $smtpemailord = get_option('smtpemailord');             $smtppasslord = get_option('smtppasslord');               $mail = new phpmailer();             $mail->issmtp(); // telling class use smtp             $mail->host       = $smtphost;      // smtp server             $mail->smtpdebug  = 1;      // enables smtp debug information (for testing)// 1 = errors , messages , // 2 = messages             $mail->smtpauth   = true;           // enable smtp authentication             $mail->smtpsecure = "ssl";                 // sets prefix servier             $mail->host       = $smtphost;      // sets gmail smtp server             $mail->port       = $smtpportlord;                   // set smtp port gmail server             $mail->username   = $smtpemailord;  // gmail username             $mail->password   = $smtppasslord;            // gmail password             $mail->subject    = $subject;             $mail->msghtml($body);             echo $email;             $mail->addaddress($email);  // sending email             echo $mail->send();                     $wpdb->query("insert `sendmail_lordlinus`(`id`,`email`,`subject`,`body`,`sent`) values('','$email','$subject','$body','1')");               } 

but when trying send mail frontend, sends mail first email- id , die code without error:

what missing in code ?

thanks

update first line

foreach($email_array $email )

and remove following line should become useless :

$email = $email_array;


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -