我正在制作一个使用 SwiftMail 扩展进行发送的控制台应用程序。根据我们的政策,我有两台虚拟机,一台用作 SMTP 中继,另一台用作应用程序服务器。通过 telnet 手动向中继发送邮件效果很好。使用 SwiftMail 时,它出现故障。
返回标头,并且没有返回任何条目$failure
变量为send()
的响应getHeaders()->toString()
Message-ID: <[email protected] /cdn-cgi/l/email-protection>
Date: Wed, 24 Oct 2012 14:50:31 -0400
Subject: [YourSite] Feedback
From: [email protected] /cdn-cgi/l/email-protection
To: [email protected] /cdn-cgi/l/email-protection
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
如果我回响send()
, i get 1
.
boot.php
$app->register(new Silex\Provider\SwiftmailerServiceProvider(), array(
'swiftmailer.options' => array(
'host' => 'ip.host.relay',
'port' => 25,
'encryption' => null,
'auth_mode' => null
),
));
app.php
$message = \Swift_Message::newInstance( )
->setSubject('[YourSite] Feedback')
->setFrom(array('[email protected] /cdn-cgi/l/email-protection'))
->setTo(array('[email protected] /cdn-cgi/l/email-protection'))
->setBody("Message!");
$app['mailer']->send($message, $failures);
当我在应用程序服务器上运行 TCP 转储并运行脚本时,没有建立 SMTP 连接,也没有抛出任何错误。
有人遇到过这个吗?由于我们的应用程序要求,我不想使用 sendmail 或 mail,而是使用 SMTP。