【发布时间】:2019-02-14 18:28:09
【问题描述】:
对于发布关于 symfony4 swiftmailer 的第 N 个问题,我提前道歉,但由于我一直无法用它发送电子邮件,我认为我的问题可能来自 symfony 的其他地方。 (nb:最后我需要让它与 GANDI 一起使用,但我首先尝试使用 GMAIL,因为更多的主题相关)。
至少这是我的配置(.env)
APP_ENV=prod (tried all with DEV too)
...
#MAILER_URL=gmail://****@gmail.com:****@localhost
#MAILER_URL=smtp://smtp.gmail.com:587?encryption=tls&username=****&password=****
#MAILER_URL=smtp://mail.gandi.net:25?encryption=tls&auth_mode=login&username=****&password=****
#MAILER_URL=smtp://mail.gandi.net:25?encryption=ssl&auth_mode=login&username=****&password=****
#MAILER_URL=smtp://mail.gandi.net:465?encryption=ssl&auth_mode=login&username=****&password=****
MAILER_URL=smtp://mail.gandi.net:587?encryption=tls&auth_mode=login&username=****&password=****
我也直接在swiftmailer.yaml中试过
swiftmailer:
transport: gmail
username: ****@gmail.com
password: *******
host: localhost
port: 465
encryption: ssl
auth-mode: login
spool: { type: 'memory' }
stream_options:
ssl:
allow_self_signed: true
verify_peer: false
verify_peer_name: false
我确实已将我的 Google 帐户设置为启用不太安全的应用程序。所有的gmail请求返回
预期的响应代码为 235,但得到代码“535”,消息为“535-5.7.8 用户名和密码不被接受。
-> 我 100% 确定我的 gmail 密码和帐户是正确的。
我的 Gandi 请求返回
预期的响应代码为 354,但得到代码“554”,消息为“554 5.5.1 错误:没有有效的收件人” [] []
-> 这是发送电子邮件的 php 代码:
$message = (new \Swift_Message('Test'))
->setFrom('****@****.com')
->setTo('****@gmail.com')
->setBody(
$this->renderView(
'email/view.html.twig',
['name' => '****', 'surname' => '****']
),
'text/html'
);
try {
$result = $mailer->send($message);
}
catch (\Exception $e) {
var_dump($e->getMessage());
}
所以我确实有收件人和发件人..
我在本地使用 Macbook 工作,是否有任何软件可以防止电子邮件离开或损坏我发送的电子邮件?
【问题讨论】:
-
尝试更改您的 Gmail 密码,然后再次尝试发送电子邮件。
-
我切换了电子邮件但没有任何改变,然后我创建了一个新的 gmailAccount 进行测试,现在它正在工作。我真的不知道为什么我的帐户被阻止了。但现在它正在使用 GMAIL。我仍然对 GANDI 有同样的问题:预期的响应代码为 354,但得到代码“554”,消息为“554 5.5.1 错误:没有有效的收件人。似乎没有人对 gandi 有类似的问题..
-
我在使用配置为
.env`MAILER_URL=smtp://mail.gandi.net:465?encryption=ssl&username=example@mail.com&password=password 的 Gandi 邮件时遇到同样的问题。我不能发邮件。只有 Gmail 有效。您找到解决方案了吗?
标签: php symfony email smtp swiftmailer