-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Revert "set schema to smtps if MAIL_ENCRYPTION === tls" #53863
Conversation
…ecking e…" This reverts commit c07f426.
symfony/mailer will always use encryption when the server advertises
When the server does not advertise It seems that many people have Anyway this reverts the changes, but would also end up making everyone who has properly set up So we would actually need an option to set the scheme, wich is not provided here. |
4.3
4.4
So when Laravel send the value framework/src/Illuminate/Mail/MailManager.php Lines 202 to 209 in b9df1f7
|
> * [BC BREAK] Removed the With your change you would set the scheme always to That's why I initially proposed the change to only include the scheme in the configuration. |
Yes, that how symfony/mailer been handling it in 7.0 and 7.1. https://github.com/symfony/mailer/blob/69c9948451fb3a6a4d47dc8261d1794734e76cdd/Transport/Smtp/EsmtpTransportFactory.php#L27 Before this, we are sending With this PR the behavior remains the same. We only had to swap
I don't disagree with that, just that the use of |
Yes but your proposed changes. $scheme = $config['scheme'] ?? null;
if (! $scheme) {
$scheme = ($config['port'] == 465) ? 'smtps' : 'smtp';
} would always yield because $autoTls = '' === $dsn->getOption('auto_tls') || filter_var($dsn->getOption('auto_tls', true), \FILTER_VALIDATE_BOOL);
$tls = 'smtps' === $dsn->getScheme() ? true : ($autoTls ? null : false); will always result in being This would correct the problem for everyone who configured Test for Port <?php
use Symfony\Component\Mailer\Transport\Dsn;
test('testing that port 465 can send mails', function () {
$dsn = new Dsn('smtps', '', '', '', 465, ['auth_mode' => 'login']);
$autoTls = '' === $dsn->getOption('auto_tls') || filter_var($dsn->getOption('auto_tls', true), FILTER_VALIDATE_BOOL);
$tls = 'smtps' === $dsn->getScheme() ? true : ($autoTls ? null : false);
expect($autoTls)
->toBeTrue()
->and($tls)
->toBeTrue()
;
}); Test for port <?php
use Symfony\Component\Mailer\Transport\Dsn;
test('testing that port 587 can send mails', function () {
$dsn = new Dsn('smtp', '', '', '', 587, ['auth_mode' => 'login']);
$autoTls = '' === $dsn->getOption('auto_tls') || filter_var($dsn->getOption('auto_tls', true), FILTER_VALIDATE_BOOL);
$tls = 'smtps' === $dsn->getScheme() ? true : ($autoTls ? null : false);
expect($autoTls)
->toBeTrue()
->and($tls)
->toBeTrue()
;
}); |
The default value inside laravel/framework/config/mail.php is If you do not have a With 11.35 you now need to explicitely set Unfortunate but I think the previous pull request changes are necessary as they fix longstanding and accidental misconfiguration in a lot of Laravel installations. MAIL_PORT and MAIL_ENCRYPTION discrepancies specifically. |
Signed-off-by: Mior Muhammad Zaki <[email protected]>
To configure 'smtp' => [
'transport' => 'smtp',
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', '127.0.0.1'),
'port' => env('MAIL_PORT', 2525),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
+ 'auto_tls' => true,
], Or, use MAIL_URL="smtp://usr:[email protected]:2525?auto_tls=true" Check the latest commits:
|
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
The previous PR (#53749) caused breaking change and that's not acceptable. |
I agree that the change should be reverted. |
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Just for cross reference as it pertains to this issue and solves it for good now: ℹ️ |
Reverts #53749
It seems that many of our Laravel users mistakenly configured
MAIL_ENCRYPTION=tls
whensymfony/mailer
would disregard this value completely and doesn't have any impact to determiningsmtp
vssmtps
ortls
configuration withinsymfony/mailer
since v4.4.Moving forward it might is best to add
scheme
to the configuration and removeMAIL_ENCRYPTION
completely.