PHPmailer多个收件人错误 [英] PHPmailer multiple recipients error
问题描述
我在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'.
如果我从数组中删除一个项目,它可以正常工作,但是在尝试添加2个或更多地址时出现错误.任何想法为什么会这样?有没有其他方法可以添加多个电子邮件地址?
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?
干杯, 瞪羚.
推荐答案
挖掘到源代码.编辑PHPMailer.php并找到"function MailSend
". (在5.0.2中,它位于第564行附近.)
Dig into the source code. Edit PHPMailer.php and find "function MailSend
". (In 5.0.2, it's around line 564.)
在上述函数中,从对mail()
的每次调用中删除 @错误抑制器.确保将 error_reporting 设置为可调试的合理值.开发时,请选择以下内容:
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');
查看PHP是否显示任何错误.仅当最后一次对mail()
的调用返回false时,或者如果从未设置$rt
时,PHPMailer才会引发实例化异常,这意味着if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1)
的值为true
.
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
.
您是否正在使用安全模式? PHP Mailer $mailer->Sender
和ini_get('safe_mode')
说什么? (我的猜测:如果您未在安全模式下运行,但将其设置为类似Off
的代码,则此代码将返回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
.)
这篇关于PHPmailer多个收件人错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!