Bre*_*ett 5 php swiftmailer yii2
我正在使用并且正在使用基本邮件程序类Yii 2
中的邮件程序,并且在大多数情况下它工作正常,但有时无法发送......所以我的代码如下:
// Let's start composing the message
$mail = Yii::$app->mailer->compose($view_data, $view_params);
//.........
// Send the message
$send = $mail->send();
Run Code Online (Sandbox Code Playgroud)
有时$send
是,false
但我不确定你如何找出它为什么是假的?有没有办法得到使它变成假的错误?
如果您要发送多个收件人消息,您应该检查是否失败:http://swiftmailer.org/docs/sending.html#getting-failures-by-reference,例如:
if (Yii::$app->mailer->getSwiftMailer()->send($message->getSwiftMessage(), $failures))
{
// do what you want with $failures var
}
Run Code Online (Sandbox Code Playgroud)
如果你真的想在 yii 应用程序中处理 smtp 错误,你应该使用 swiftmailer 记录器插件:http://swiftmailer.org/docs/plugins.html#logger-plugin
PS:首先我会检查 yii 和 smtp 日志,看看发生了什么类型的错误......
归档时间: |
|
查看次数: |
8067 次 |
最近记录: |