使用phpMailer甚至无法使用爆炸发送电子邮件给多个收件人

时间:2015-05-16 18:26:09

标签: php email phpmailer

我尝试使用phpMailer将电子邮件发送到多个电子邮件地址也使用了爆炸,以便通过数组解析值,但没有任何效果。 以下是我的完整代码:

<?php
include 'connect.php';

$emailID = $_POST['email'];

$sql = '

    SELECT  *
    FROM    customerEmails
    WHERE   customerEmailID = ' . $emailID . '
    ';

$result = mysql_query($sql) or die(mysql_error());

$contents   = mysql_fetch_array($result);

$to     = $contents['customerEmailTo'];

$from   = $contents['customerEmailFrom'];

$subject= $contents['customerEmailSubject'];

$body   = $contents['customerEmailBody'];


include_once($_SERVER['DOCUMENT_ROOT'].'/pyramid/phpmailer/class.phpmailer.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/pyramid/phpmailer/class.smtp.php');

$mail = new PHPMailer(true); 

$mail->IsSMTP(); // send via SMTP

$mail->SMTPAuth = true; // turn on SMTP authentication

$mail->SMTPSecure="tls";

$mail->Host="smtp.office365.com";

$mail->Port=587;

$mail->Username = “xxxxxxx”; // SMTP username

$mail->Password = “xxxxxxxx”; // SMTP password

$webmaster_email = "xxxxxxxx"; //Reply to this email ID

$email=$to; // Recipients email ID

$mail->SMTPDebug = false; //1;

$name=""; // Recipient's name

$mail->From = $webmaster_email;

$mail->FromName = "XYZ";

**$addresses = explode(‘;’,$_POST[‘$to’]);

    foreach ($addresses as $email){
    $mail-> AddAddress($email);
}**

$mail->AddBCC($webmaster_email, "Info");

$mail->AddReplyTo($webmaster_email,"XYZ");

$mail->WordWrap = 50; // set word wrap

//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment

$mail->IsHTML(true); // send as HTML

$mail->Subject = $subject;
$mail->Body = $body;

//$mail->AltBody = "This is the body when user views in plain text format"; //Text Body

if(!$mail->Send()){

    echo "Mailer Error: " . $mail->ErrorInfo;

}else{

    //Save date for email sending

    $sqlBlotDate = '

        UPDATE  customeremails

        SET     dateEmailSent = CURRENT_TIMESTAMP()
        WHERE   customerEmailID = ' . $emailID

    ;
    mysql_query($sqlBlotDate);


    echo "Message has been sent";

}



include 'disconnect.php';
?>

0 个答案:

没有答案