PHP 的 mail() 函数可以正常发送邮件,但 Swiftmailer 的 Swift_MailTransport 不起作用!
这有效:
mail('user@example.com', 'test '.date('H:i:s'), '');
但这不会:
$transport = Swift_MailTransport::newInstance('');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('test '.date('H:i:s'))
->setFrom('user@example.com')
->setTo('user@example.com')
->setBody('Testing one two three');
$result = $mailer->send($message);
(user@example.com
在我的测试代码中替换为有效的电子邮件地址。)
在这两种情况下,这两个事件的邮件日志看起来非常相似,并且似乎是在后者中发送邮件。
Swiftmailer 构建的消息是否会导致它被垃圾邮件过滤器阻止?
(顺便说一句,我尝试过使用 SMTP 传输,但没有运气;我认为由于 mail() 工作正常,切换到 Swiftmail 的邮件传输将是微不足道的......)