【发布时间】:2015-04-21 14:05:27
【问题描述】:
我正在使用 swift_mailer 处理发送电子邮件,但我遇到了一个问题,即电子邮件没有发送,send 方法的返回值始终为零。
app/config/config.yml
swiftmailer:
transport: smtp
host: <host> # of the company
username: <username> # of the company
password: <password> # of the company
port: 25
app/config/config_test.yml
swiftmailer:
disable_delivery: true
# disable_delivery: ~ # tried with this too
控制器
$mailer = $this->get('mailer');
$message = $mailer->createMessage()
->setSubject('You have Completed Registration!')
->setFrom('send@example.com')
->setTo('valid_email@Iswear.fr')
->setBody(
'hello world!!',
'text/plain'
)
var_dump($mailer->send($message, $failed), $failed); exit;
输出:
int(0)
array(0) {
}
我知道 send 返回电子邮件已发送给的人数。为什么永远不会发送电子邮件? 鉴于我确定我要发送到的唯一电子邮件地址。
更新1:
我想知道如何进一步调试。
【问题讨论】:
-
你在哪个环境? disable_delivery 不发送任何电子邮件,(用于测试或开发...)
-
swiftmailer: disable_delivery: 在开发环境中为真 => 在开发环境中永远不会发送电子邮件
-
尝试 disable_delivery: false
-
@pcm 这是预期的,但发送方法应该返回 1,不是吗?
-
不一定。如果你想实现一个测试环境,disable_delivery 不是答案。
标签: php email symfony smtp swiftmailer