【问题标题】:Swift Mailer long delaySwift Mailer 长时间延迟
【发布时间】:2013-11-08 11:23:09
【问题描述】:

我对 swiftmailer 有一个奇怪的问题。当我尝试发送电子邮件时,页面加载最多需要 3 分钟,并且没有发送任何电子邮件。 这是我使用的代码:

$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance()
->setSubject("test")
->setTo(array('foo@bar.com' => "testasdsadasd"))
->setFrom(array('asdasd@dsfsf.com' => 'asdasd@sdfsf.com'))
->setBody($body, 'text/html');
$mailer->send($message);

这是我尝试调试时使用的代码。 var_dump 的结果是 array(0) { }

$transport = Swift_MailTransport::newInstance();
$body = "Test";
$message = Swift_Message::newInstance()
->setSubject("test")
->setTo(array('foo@bar.com' => "testasdsadasd"))
->setFrom(array('asdasd@dsfsf.com' => 'asdasd@sdfsf.com'))
->setBody($body, 'text/html');
$mailer = Swift_Mailer::newInstance($transport);
#$mailer->send($message);

$logger = new Swift_Plugins_Loggers_EchoLogger();
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));

$result = $mailer->send($message, $failures);
var_dump($failures);

【问题讨论】:

    标签: php email swiftmailer


    【解决方案1】:

    你的 SwiftMailer 配置好吗? 您使用哪种运输工具? 如果你使用sendmail,你必须在文件/etc/hosts中添加一行 它应该看起来像这样:127.0.0.1 localhost localhost.localdomain

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多