symfony: Mailer Transports to SMTP Cannot Establish Secure Connections

Symfony version(s) affected: 5.0.1

Description
When using the Transport out of the box, the Transport is unable to establish a secure connection. This issue looks similar to https://github.com/symfony/symfony/issues/34064

I am using OpenSSL 1.1.1d and PHP 7.4. I’ve reproduced the issue on PHP 7.3 as well.

The exact error message I receive is:

Connection could not be established with host "ssl://smtp.postmarkapp.com:587": stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:1408F10B:SSL routines:ssl3_get_record:wrong version number

How to reproduce

$transport = new PostmarkSmtpTransport($key);
$mailer = new Mailer($transport);
$mail = (new Email)->to('test@example.com')
->from('test@example.com')
->subject('Test Email')
->html('Test Email');
$mailer->send($mail);

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

To be clear, you should use 465, true to use SSL to connect or 587, false to connect withou SSL and upgrade via STARTTLS. Any other combination won’t work. The code was buggy, fixing it here:

I applied the patch in #34760 without success in resolving this bug.

MAIL_MAILER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=587 MAIL_USERNAME=myuser MAIL_PASSWORD=mypass MAIL_ENCRYPTION=STARTTLS

When I set env values like this, there is no error. but email not send to target email.

@hanzallahmsd did you try

MAIL_ENCRYPTION=starttls