I am trying to send emails to multiple email addresses using php mailer but its not working. I've tried explode the addresses but nothing seems to work. here is my code
html:
<input type="text" name="addresses" value="{$addresses}"/>
current output in the input is test1@gmail.com,test2@gmail.com,test3@gmail.com,
php to send email:
/* Get Customer info*/
$sql = mysql_query("SELECT * FROM customer WHERE ID='$id' LIMIT 1");
$sql=mysql_fetch_array($sql);
$fname=$sql['FIRST_NAME'];
$lname=$sql['LAST_NAME'];
$company=$sql['COMPANY'];
$customer_email=$sql['EMAIL'];
$email_addresses=$VAR['addresses'];
if($email_addresses != "" && $customer_email !=""){
$emailto=$email_addresses;
}elseif($email_addresses == "" && $customer_email !=""){
$emailto=$customer_email;
}
/* Get Email Options */
$r=mysql_query("SELECT * FROM `email` WHERE `ID`=1");
$r=mysql_fetch_array($r);
$emailfrom=$r['EMAIL_FROM'];
$emailpriority=$r['EMAIL_PRIORITY'];
$emailsubject=$r['EMAIL_SUBJECT'];
/* Headers */
$subject = "$emailsubject";
$mailer = "$emailfrom";
$headers = "From: $mailer \r\n";
$headers .= "Reply-To: $mailer\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n boundary=\"PHP-mixed- ".$random_hash."\"";
$headers .= "Importance: $emailpriority\r\n";
$email = new PHPMailer();
$email->From = $mailer;
$email->FromName = $mailer;
$email->Subject = $subject;
$email->Body = $message;
$email->AddAddress( $emailto );
$email->isHTML(true);
$email->Send();
so if I have one recipient in the input box it send the email fine but if I have multiple and separate them with , it does not send the email. i've tried $emailto=explode(',',$email_addresses); since I am separating the email with , but that does not work. any suggestion would be great.