【发布时间】:2012-05-23 22:58:43
【问题描述】:
SwiftMail 不发送我的电子邮件,而 mail() 确实有效。与here相同。
我添加了 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,但为什么?
更新
在Swift_Transport_SimpleMailInvoker::mail我把参数转储出来了:
$headers =>
string(208) "Message-ID: <1337173064.4fb3a4480b8dd@domain.de>
Date: Wed, 16 May 2012 14:57:44 +0200
From: news@domain.de
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
"
$extraParams =>
string(15) "-fnews@domain.de"
$to, $subject, $body 与我在mail() 中使用的相同。仍然不知道问题出在哪里。
更新 #2
这对我来说很好用:
mail($email, 'Test', $nl_text, "From: " . ABSENDER);
免责声明:这不是解决方案,而是我使用的解决方法,因为我没有时间调试框架并找到真正的解决方案。随意使用上面提供的信息来调试自己并在此处发布您的解决方案。我很乐意接受并投票。
【问题讨论】:
-
你能解决这个问题吗?
-
我的解决方案是用一个简单的
mail($email, 'Anmeldung', $nl_text, "From: " . ABSENDER);替换它,但它并没有解决问题,所以我投了反对票,最后删除了我的答案。这个问题需要一些调试,但我没有时间。 -
很好,您应该将其发布为答案。
标签: php email swiftmailer