duanna2026 2010-02-17 00:25
浏览 45
已采纳

PHPmailer多个收件人错误

I have the following code with PHPmailer:

$tomailn[0] = 'imap2@gazler.com';
$tomailn[1] = 'imap@gazler.com';
foreach($tomailn as $value)
{
$mail->AddAddress($value, '');
}

But I am getting the error 'Could not instantiate mail function'.

If I remove an item from the array it works fine, but gives an error on when trying to add 2 or more addresses. Any ideas why this is happening? Is there a different way to add multiple e-mail addresses?

Cheers, Gazler.

  • 写回答

6条回答 默认 最新

  • duanhong1985 2010-02-20 22:09
    关注

    Dig into the source code. Edit PHPMailer.php and find "function MailSend". (In 5.0.2, it's around line 564.)

    In said function, remove the @ error suppressor from each call to mail(). Make sure error_reporting is set to something reasonable for debugging. When developing, choose something like this:

    error_reporting(E_ALL | E_STRICT);
    ini_set('log_errors', 'On');
    ini_set('display_errors', 'On');

    See if PHP shows any errors. PHPMailer only throws the instantiate exception when the last call to mail() returns something falsey, or if $rt never gets set, which would mean that if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) evaluates to true.

    Are you using safe mode? What do PHP Mailer $mailer->Sender and ini_get('safe_mode') say? (My guess: if you are not running in safe mode, but have it set to something like Off, this code would return true.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!