【发布时间】:2014-06-13 18:20:31
【问题描述】:
我必须使用 PhpMailer 发送多封邮件。以下是我的代码:
<?php
include 'class.phpmailer.php';
$friendsarr=array('test1@gmail.com','test2@example.com');
$mail = new PHPMailer();
$mail->From = 'test3@test.com';
$mail->FromName = 'CK';
$mail->Subject = 'FW:'.'Test';
$mail->AltBody = '';
$i=0;
foreach ($friendsarr as $value) {
$mail2 = clone $mail;
$friendmail=$value;
$message='<table border="0" align="left" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td height="28">
<div>
<div align="right"><a href="http://integrationyantra.com/en/?join=1" style=""><strong>Subscribe Me!</strong></a></div>
<div align="left">Dear Recipient,<br/>CK has forwarded this email to you with the following message: test</div><br/><div><strong>Please Note: </strong>You have <strong>NOT</strong> been added to any email lists. If you no longer wish to recieve these messages, please contact <a href="#">test4@test.com</a>.</div>
<br/><div align="left">test here'.$i.'</div>
</div>
</td>
</tr>
</tbody>
</table>';
$mail2->MsgHTML($message);
$mail2->AddAddress($value, 'Recipient');
$sent=$mail2->Send();
echo $sent.' '.$value.'<br/>';
$mail2->ClearAddresses();
$i++;
}
?>
值$sent 显示1,但邮件不会发送到任何邮件地址。也没有错误。谁能告诉我缺少什么?
【问题讨论】:
-
可能是它的服务器问题,因为很少有服务器不接受这种邮件功能..您应该尝试使用 SMTP 身份验证发送电子邮件..检查此链接email.about.com/od/emailprogrammingtips/qt/…
-
系统日志、mail.log、php 错误日志或网络服务器错误日志中可能出现错误。