[2.x] fix: disable auto_tls for None encryption, add SSL cert verification bypass#4445
Merged
[2.x] fix: disable auto_tls for None encryption, add SSL cert verification bypass#4445
Conversation
…ation bypass option Fixes two bugs in the SMTP driver (issue #4439): 1. When encryption is set to "None", Symfony's EsmtpTransport was silently negotiating STARTTLS if the server advertised it. Passing auto_tls=false to the DSN opts out of this behaviour so the connection stays plaintext as intended. 2. There was no way for administrators to disable SSL certificate verification, making the driver unusable with internal mail servers that use self-signed certificates. A new "Verify SSL Certificate" boolean toggle (mail_smtp_verify_peer) passes verify_peer=false when disabled. Also refactors SmtpDriver to depend on TransportFactoryInterface rather than the final EsmtpTransportFactory, and adds unit tests for all five built-in mail drivers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4439
Summary
Two bugs in the SMTP driver, both present since the Symfony Mailer migration:
Bug 1 — None encryption silently upgrades to STARTTLS. When "None" is selected,
EsmtpTransportwas opportunistically negotiating STARTTLS if the server advertised it. Fix: passauto_tls=falsein the DSN options so the connection stays plaintext as configured.Bug 2 — No way to bypass SSL certificate verification. Administrators using internal mail servers with self-signed certificates had no way to proceed. Fix: new boolean admin setting "Verify SSL Certificate" (
mail_smtp_verify_peer); when disabled,verify_peer=falseis passed in the DSN options.Changes
SmtpDriver: addsauto_tls=falsefor None encryption,verify_peeroption, newmail_smtp_verify_peersettingSmtpDriver: depends onTransportFactoryInterfaceinstead of thefinalEsmtpTransportFactory(better design, enables unit testing)MailServiceProvider: bindsTransportFactoryInterface → EsmtpTransportFactoryMailPage.tsx: type detection now handlesboolean → 'bool'(renders a toggle switch)core.yml: addsmail_smtp_verify_peer_labelandmail_smtp_verify_peer_helpTests
SmtpDriverTest: 10 unit tests covering scheme selection,auto_tls, andverify_peerfor all encryption modesMailTest(integration): updated expected smtp fields to includemail_smtp_verify_peerNullDriverTest,SendmailDriverTest,LogDriverTest(includingFlarumLogTransportbehaviour),MailgunDriverTest(including validation rules)Test plan
./vendor/bin/phpunit tests/unit/Mail/./vendor/bin/phpunit tests/integration/extenders/MailTest.php