Swiftmailer失败而不是处理失败

时间:2019-07-15 04:53:01

标签: validation email swiftmailer verification

我正在使用Swiftmailer,遇到一个奇怪的问题。 Swiftmailer smetimes抛出未处理的异常,而不是发送失败代码。

我正在使用这种基本方法:

$mailer = new Swift_Mailer( ... );

$message = (new Swift_Message( ... ))
  ->setFrom( ... )
  ->setTo([
    'receiver@bad-domain.org' => 'Receiver Name',
    'other@domain.org' => 'A name',
    'other-receiver@bad-domain.org' => 'Other Name'
  ))
  ->setBody( ... )
  ;

// Pass a variable name to the send() method
if (!$mailer->send($message, $failures))
{
  echo "Failures:";
  print_r($failures);
}

/*
Failures:
Array (
  0 => receiver@bad-domain.org,
  1 => other-receiver@bad-domain.org
)
*/

如果我尝试将电子邮件发送到某个域上不存在的用户名(该域存在,而邮箱不存在),它不会显示失败,只是退出端会出现错误:

  

[2019年7月14日周日7:26:54.862437] [fcgid:warn] [pid 20822:tid   140184301594368] [rid:XSq9D2 @ SNz7yItJNuaKn-QAAAME] [客户端    *。****。* 。****:0] mod_fcgid:stderr:PHP致命错误:未捕获的Swift_TransportException:预期的响应代码354但得到了代码   消息为“ 503”的“ 503”-拒绝了所有RCPT命令   错误:

谁知道为什么?

0 个答案:

没有答案