SwiftMail 不发送我的电子邮件,而mail()
确实有效。与...一样here https://stackoverflow.com/questions/3552937/swiftmailer-wont-send-mail-but-mail-will.
我添加了 EchoLogger,但它不打印任何内容。
$message = Swift_Message::newInstance();
$message->setSubject('Test');
$message->setTo( $email );
$message->setFrom(ABSENDER);
$message->setBody($nl_text);
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$logger = new Swift_Plugins_Loggers_EchoLogger();
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
$result = $mailer->send($message, $failures);
var_dump($failures);
电子邮件返回于$failures
但为什么?
Update
In Swift_Transport_SimpleMailInvoker::mail
我转储了参数并得到了这个:
$headers =>
string(208) "Message-ID: <[email protected] /cdn-cgi/l/email-protection>
Date: Wed, 16 May 2012 14:57:44 +0200
From: [email protected] /cdn-cgi/l/email-protection
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
"
$extraParams =>
string(15) "[email protected] /cdn-cgi/l/email-protection"
$to, $subject, $body
和我用的一样mail()
。仍然不知道问题是什么。
更新#2
这对我来说效果很好:
mail($email, 'Test', $nl_text, "From: " . ABSENDER);
免责声明:这不是一个解决方案,而是我使用的解决方法,因为我没有时间调试框架并找到真正的解决方案。请随意使用上面给出的信息自行调试并在此处发布您的解决方案。我会很乐意接受并投票。