Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mailer] EsmtpTransport TLS option #36005

Closed
Flower7C3 opened this issue Mar 9, 2020 · 5 comments
Closed

[Mailer] EsmtpTransport TLS option #36005

Flower7C3 opened this issue Mar 9, 2020 · 5 comments

Comments

@Flower7C3
Copy link

Symfony version affected: 5.0.5

Description
I am not sure if it is really bug, or I am using something in wrong way. But when I want to setup EsmtpTransport with no TLS option it will be launched anyway. It was created on Aug 19, 2019 and still exists in master code.

@sebheitzmann
Copy link

i've got the same error.

MAILER_DSN=smtp://mail.2le.net:25

and when I try to send something :

In SocketStream.php line 154:
                                                                                                     
  Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:  
  error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed               
                                                                                                     

sebheitzmann added a commit to sebheitzmann/mailer that referenced this issue Mar 25, 2020
I thinks that this condition is false. We should not call startTLS if we are not in TLS.
see symfony/symfony#36005
sebheitzmann added a commit to sebheitzmann/symfony that referenced this issue Mar 25, 2020
I thinks that this condition is false. We should not call startTLS if we are not in TLS.
see symfony#36005

That's my first PR on symfony, so please say me if it's not the right way to do.
sebheitzmann added a commit to sebheitzmann/symfony that referenced this issue Mar 25, 2020
I thinks that this condition is false. We should not call startTLS if we are not in TLS.
see symfony#36005

That's my first PR on symfony, so please say me if it's not the right way to do.
@Flower7C3
Copy link
Author

I find out one solution for this is to disable SSL verify_peer and verify_peer_name. But I still thinks that there is a bug in the code I mention above.

$socketStreamOptions = json_decode('{"ssl":{"verify_peer":false,"verify_peer_name":false}}');

 /** @var Transport\Smtp\EsmtpTransport $transport */
$transport = Transport::fromDsn($dsn);

/** @var Transport\Smtp\Stream\SocketStream $socketStream */
$socketStream = $transport->getStream();
$socketStream->setStreamOptions($socketStreamOptions);

$mailer = new Mailer($transport);

@stof
Copy link
Member

stof commented Mar 25, 2020

Well, if your SMTP server advocates STARTTLS support but does not have a valid cert, the bug is in your SMTP setup, not in Symfony.

@sebheitzmann
Copy link

Thanks for the advice. I will check that.

@sebheitzmann
Copy link

It's ok. The posfix config was wrong. Sorry. You can close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants