斯威夫特梅勒长时间拖延

时间:2013-10-29 10:43:59

标签: php email swiftmailer

我对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);

1 个答案:

答案 0 :(得分:0)

你的SwiftMailer配置好吗? 你用哪种运输车? 如果您使用sendmail,则必须在文件/etc/hosts中添加一行 它应该如下所示:127.0.0.1 localhost localhost.localdomain