Php Swift邮递长延迟
我对swiftmailer有一个奇怪的问题。当我尝试发送电子邮件时,页面加载最多需要3分钟,并且没有发送电子邮件。 以下是我使用的代码:Php Swift邮递长延迟,php,email,swiftmailer,Php,Email,Swiftmailer,我对swiftmailer有一个奇怪的问题。当我尝试发送电子邮件时,页面加载最多需要3分钟,并且没有发送电子邮件。 以下是我使用的代码: $transport = Swift_MailTransport::newInstance(); $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance() ->setSubject("test") ->setTo(array('f
$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的结果是数组(0){}
您的SwiftMailer配置是否正常? 你使用哪种运输工具? 如果使用sendmail,则必须在文件
/etc/hosts
它应该是这样的:127.0.0.1 localhost localhost.localdomain
$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);