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