You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the beginning of last year, someone was unable to connect to an email server (#40887). I cannot really follow what the underlying problem eventually is, but a pull request (#40943) is made that fixes the issue and everything is closed.
The problem is that in that PR, the configuration is locked down the smtps scheme for Symfony Mailer is only set in case MAIL_ENCRYPTION is set to tls and MAIL_PORT is set to 465. The problem is that if you would like to connect to a SMTP server via TLS directly on a port other than 465, there is no way to configure this.
My hunch is that somewhere along the way TLS and STARTTLS got confused. As a recap (per Mailtrap), TLS means that the whole SMTP connection is encapsulated in TLS. This is often called SMTPS. Whereas with STARTTLS, the connection will start as a regular SMTP connection and get upgraded to TLS during the handshake.
The scheme Symfony Mailer refers to determines the TLS status, so smtps is used for SMTP over TLS, where as smtp is used for plain SMTP, with a potential upgrade using STARTTLS. The extra confusing thing is that Symfony Mailer deprecated explicit STARTTLS options in version 4.4, meaning that from this version onwards it will automatically upgrade a connection with STARTTLS if it is available.
I would like to make it possible to use SMTPS for ports other than 465. This is a valid use case since some cloud providers block common SMTP ports (20, 465, 587) and thus offer alternative ports (e.g. Scaleway offers SMTP over TLS on port 2465.
Hence, I propose to revert PR #40943 and will submit a PR soon for doing so soon. Using STARTTLS was already perfectly possible before the PR, but this meant users had to set MAIL_ENCRYPTION to null. I get that this is counter-intuitive, so maybe it is a good idea to add some docs and/or consider dropping MAIL_ENCRYPTION so developers know how to deal with this.
Create a new Laravel application, and attempt to send out an email to a TLS SMTP-server on a port other than 465 (e.g. 2465). The connection will time-out and the following error will be thrown:
Symfony\Component\Mailer\Exception\TransportException with message 'Connection could not be established with host "server:2465": stream_socket_client(): Unable to connect to server:2465 (Operation timed out)'
The text was updated successfully, but these errors were encountered:
Slight addition: I noticed some speak that TLS was hard-locked to port 465 in the other issue. I have just tested a branch which reverts the PR and it is perfectly possible to send email over TLS using a non-465 port, so I feel this shouldn't be a blocker.
leinelissen
added a commit
to leinelissen/framework
that referenced
this issue
Feb 1, 2023
Description:
At the beginning of last year, someone was unable to connect to an email server (#40887). I cannot really follow what the underlying problem eventually is, but a pull request (#40943) is made that fixes the issue and everything is closed.
The problem is that in that PR, the configuration is locked down the
smtps
scheme for Symfony Mailer is only set in caseMAIL_ENCRYPTION
is set totls
andMAIL_PORT
is set to465
. The problem is that if you would like to connect to a SMTP server via TLS directly on a port other than 465, there is no way to configure this.My hunch is that somewhere along the way TLS and STARTTLS got confused. As a recap (per Mailtrap), TLS means that the whole SMTP connection is encapsulated in TLS. This is often called SMTPS. Whereas with STARTTLS, the connection will start as a regular SMTP connection and get upgraded to TLS during the handshake.
The scheme Symfony Mailer refers to determines the TLS status, so
smtps
is used for SMTP over TLS, where assmtp
is used for plain SMTP, with a potential upgrade using STARTTLS. The extra confusing thing is that Symfony Mailer deprecated explicit STARTTLS options in version 4.4, meaning that from this version onwards it will automatically upgrade a connection with STARTTLS if it is available.I would like to make it possible to use SMTPS for ports other than 465. This is a valid use case since some cloud providers block common SMTP ports (20, 465, 587) and thus offer alternative ports (e.g. Scaleway offers SMTP over TLS on port 2465.
Hence, I propose to revert PR #40943 and will submit a PR soon for doing so soon. Using STARTTLS was already perfectly possible before the PR, but this meant users had to set
MAIL_ENCRYPTION
tonull
. I get that this is counter-intuitive, so maybe it is a good idea to add some docs and/or consider droppingMAIL_ENCRYPTION
so developers know how to deal with this.Pinging @driesvints and @nicolalazzaro since you were involved with the mentioned issue and PR.
Steps To Reproduce:
Create a new Laravel application, and attempt to send out an email to a TLS SMTP-server on a port other than 465 (e.g. 2465). The connection will time-out and the following error will be thrown:
The text was updated successfully, but these errors were encountered: