Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Mailer] Force disable STARTTLS #49114

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

Closed
filippovano opened this issue Jan 26, 2023 · 11 comments · Fixed by #53621
Closed

[Mailer] Force disable STARTTLS #49114

filippovano opened this issue Jan 26, 2023 · 11 comments · Fixed by #53621
Labels

Comments

@filippovano
Copy link

Description

I have an SMTP server that sits between my application and other external systems. Communication between my application and the server does not use any encryption. Encryption is used when the server communicates with external systems.

I need to send an email from my app to a server without any encryption. When I use the symfony/mailer the application sends an ECHO request and my server tells me that it is using STARTTLS. I have to send STARTTLS and my server says it doesn't support encryption for my host.

It all happens because of this line:

// https://github.com/symfony/mailer/blob/6.1/Transport/Smtp/EsmtpTransport.php#L136

if (!$stream->isTLS() && \defined('OPENSSL_VERSION_NUMBER') && \array_key_exists('STARTTLS', $this->capabilities)) {

I know for sure that I don't need to use any encryption regardless of whether the STARTTLS server sends me. But I can't disable STARTTLS in any way, because there is no setting (for ex. disable_starttls) in the configs.

I think it makes sense to add this setting, it will make the package more flexible.

Example

No response

@filippovano filippovano changed the title Force disable STARTTLS [Mailer] Force disable STARTTLS Jan 26, 2023
@stof
Copy link
Member

stof commented Jan 26, 2023

Well, if your SMTP server does not support STARTTLS, why would it advocate STARTTLS in its capabilities ? That's expliictly against the spec.

The symfony/mailer component will use STARTTLS only if the SMTP server advocates that it supports it (and we are not already using a TLS connection to that server as double encryption would be useless).

@derrabus
Copy link
Member

We've had similar issues with maildev and decided to not fix this on Symfony's side, see #34242.

@h2Entwicklung
Copy link

Hallo @derrabus @stof,

I found this issue here and I think this is a realy bad behaviour.
We had the issue that a wrongly configured SMTP-Server but we where not able to get the administrator of the server to fix it. So we had no chance to get the application running only by removing th "!" infront of the if clause.

So I had to explain the user that he can't use the application because of his wrong configured SMTP-Server.

I know that in a perfect world this is the right way, but there a a lot of administors out there who are not able to configure a SMTP-server the correct way.
I hope you can build this switch to enforce disable TLS.

@stof
Copy link
Member

stof commented May 16, 2023

@h2Entwicklung note that removing the ! will not fix the issue: it will make your connection work with your broken server but will break usage with spec-compliant servers.

@srsbiz
Copy link
Contributor

srsbiz commented Jun 30, 2023

In our case app is hosted on windows server, in internal corporate network with some kind of proprietary SMTP gateway that "ensures email security", and we can not use anything else. Of course it reports STARTTLS capability, but does not work with PHP.

We have mitigated this by creating copy of EsmtpTransportFactory that supports only "smtp" scheme and always passes false as $isTls argument to new EsmtpTransport instance. Instruction for registering custom mailer transports: https://albertmoreno.dev/posts/creating-custom-symfony-mailer-transports/

@kwisatz
Copy link

kwisatz commented Jul 18, 2023

Well, if your SMTP server does not support STARTTLS, why would it advocate STARTTLS in its capabilities ? That's expliictly against the spec.

The symfony/mailer component will use STARTTLS only if the SMTP server advocates that it supports it (and we are not already using a TLS connection to that server as double encryption would be useless).

See the use-case described above in nextcloud/server#39452.

The fact that the smtpd announces STARTTLS capability does not mean that it has a valid certificate for e.g. private IPs or domains that are resolved only internally.

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@mgrundkoetter
Copy link

We have the same problem. Server admin says he can't/won't change the config so the application is unable to send any emails. Explicit option like in swiftmailer encryption=false would be nice.

@carsonbot carsonbot removed the Stalled label Jan 23, 2024
@xabbuh
Copy link
Member

xabbuh commented Jan 23, 2024

Can you take a look at #53545 (comment) and provide some feedback if updating the stream context as described there does work?

@mgrundkoetter
Copy link

Thats not really a solution as this would mean to change all code pieces where mails are sent. We need an option to globally enable/disable this via config.

@xabbuh
Copy link
Member

xabbuh commented Jan 23, 2024

Can you please try it nonetheless so that we can at least figure out a potential pass on how to implement this feature?

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

Successfully merging a pull request may close this issue.

9 participants