我一直在使用 phpmailer 发送批量电子邮件时遇到问题,但一封电子邮件没有问题。
这是我的代码:
$result = mysql_query("select * from $to",$conn) or die("list
selected ($to) does not exist ".mysql_error());
while ($row = mysql_fetch_array($result))
{
$email[] = $row['email'];
$student[] = $row['name'];
}
foreach ($email as $val => $uemail) {
$email = $uemail;
$students= $student[$val] ;
require("class.phpmailer.php");
$mail = new PHPMailer(true);
try {
$mail->AddReplyTo('info@bratim.com', 'My Name');
$mail->AddAddress("$email", "$student");
$mail->SetFrom('info@me.com', 'MyName');
$mail->AddReplyTo('info@me.com', 'My nameg');
$mail->Subject = "$sub";
$mail->MsgHTML("Dear $student<br> $msg <br>
<img src=\"$path\"> <p>
$host_upper
______________________________________________________
THIS IS AN AUTOMATED RESPONSE.
***DO NOT RESPOND TO THIS EMAIL****
");
$mail->AddAttachment("$path2"); // attachment
$mail->Send();
echo "Message Sent OK to $email </p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
}
任何帮助,建议将不胜感激。