我正在制作一个使用 SwiftMail 扩展发送的控制台应用程序。由于我们的政策,我有两台虚拟机,一台用作 SMTP 中继,另一台用作应用程序服务器。通过 telnet 手动将邮件发送到中继可以正常工作。使用 SwiftMail 时,它已损坏。
$failure
返回标头,并且在变量中没有返回条目send()
的回应getHeaders()->toString()
Message-ID: <1351104631.508838778dc03@swift.generated>
Date: Wed, 24 Oct 2012 14:50:31 -0400
Subject: [YourSite] Feedback
From: noreply@localhost.com
To: sixeightzero@localhost.com
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
如果我回应send()
,我得到1
。
引导.php
$app->register(new Silex\Provider\SwiftmailerServiceProvider(), array(
'swiftmailer.options' => array(
'host' => 'ip.host.relay',
'port' => 25,
'encryption' => null,
'auth_mode' => null
),
));
应用程序.php
$message = \Swift_Message::newInstance( )
->setSubject('[YourSite] Feedback')
->setFrom(array('noreply@localhost.com'))
->setTo(array('sixeightzero@localhost.com'))
->setBody("Message!");
$app['mailer']->send($message, $failures);
当我在应用服务器上运行 TCP 转储并运行脚本时,没有建立 SMTP 连接,也没有抛出错误。
有人遇到过这种情况吗?由于我们的应用程序要求,我不想使用 sendmail 或邮件,而是使用 SMTP。