3

I want to convert my mailing from Swift Mailer to the Mailer Component, since I upgraded to Symfony 4.3.

I've translated my MAILER_URL to a MAILER_DSN, the following way:

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

As you can see, I'm using Zoho as my mail provider.

However, I'm getting the following internal server error:

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

I've tried switching from SSL to TLS, with no (different) result.

The code I've written to send my test mail, is as follows:

$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);

I expect my code to send a mail to "foo@bar.com", but instead it turns the empty response as described.

Majesteit
  • 183
  • 1
  • 9
  • 1
    Have you tried setting a breakpoint (or var_dumping) the parsed DSN inside Symfony Mailer's Transport: https://github.com/symfony/mailer/blob/ca3a1473069c3c14080698d27ab6a30c15701b19/Transport.php#L75 & https://github.com/symfony/mailer/blob/ca3a1473069c3c14080698d27ab6a30c15701b19/Transport.php#L173-L182? Maybe the DSN is not parsed correctly for some reason. – dbrumann Jun 17 '19 at 14:35
  • I can verify that it is parsing correctly. The authentication works, it just returns an empty response for some reason... – Majesteit Jun 17 '19 at 16:46
  • Have you tried using port 587 instead of 465? – sylvery May 29 '20 at 05:12

1 Answers1

0

The problem is the the "@" in the username must be encoded:

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

Credit to fabpot. Here is the link to his answer https://github.com/symfony/symfony/issues/32148#issuecomment-517903812