为什么Symfony Mailer组件返回空响应?

时间:2019-06-17 14:23:15

标签: symfony components mailer zoho dsn

自从我升级到Symfony 4.3之后,我想将邮件从Swift Mailer转换为Mailer Component。

我已通过以下方式将我的MAILER_URL转换为MAILER_DSN:

MAILER_URL=smtp://smtp.zoho.eu:465?encryption=ssl&auth_mode=login&username=bar@foo.com&password=password123
MAILER_DSN=smtp://bar@foo.com:password123@smtp.zoho.eu:465/?encryption=ssl&auth_mode=login

如您所见,我正在使用Zoho作为我的邮件提供商。

但是,我收到以下内部服务器错误:

Expected response code "250" but got an empty response.

我尝试从SSL切换到TLS,但没有(不同)结果。

我为发送测试邮件而编写的代码如下:

$email = (new TemplatedEmail())
  ->from('bar@foo.com')
  ->to('foo@bar.com')
  ->subject('Test')
  ->htmlTemplate('email.html.twig')
  ->context([
    'expiration_date' => new \DateTime('+7 days'),
    'username' => 'foo',
  ])
;

$this->mailer->send($email);

我希望我的代码可以将邮件发送到“ foo@bar.com”,但相反,它会按照说明将响应设为空。

1 个答案:

答案 0 :(得分:0)

问题在于用户名中的“ @”必须进行编码:

MAILER_DSN=smtp://bar%40foo.com:password123@smtp.zoho.eu:465/?encryption=ssl&auth_mode=login

贷给fabpot。这是他的答案https://github.com/symfony/symfony/issues/32148#issuecomment-517903812

的链接