-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Winter 1.2 not using SMTP settings from database #626
Comments
I'd be happy to continue helping with this, just need some more pointers to look at please. |
I tried replicating this with your procedure and I couldn't. The proper config gets passed from what's provided in the form, and mail gets sent properly. I had no config in the config/mail.php (other than default values) |
I also added |
Thank you for helping. The only other plugin I have but not enabled is the Gmail email sending one. I'll try again today. |
It's possible the gmail plugin is interfering, try removing/disabling it. |
I've removed the gmail plugin and deleted the files. What else might it be please? |
Does trace_log($config); echo an output automatically or should it be done separately? |
It should work, please show how you debug this. Also, show the output of |
it sends the output to your |
I've added "trace_log($config)" to the "resolve" function in winter\storm\src\Mail\MailManager.php [2022-07-23 17:34:37] development.INFO: Array I then added the same function into the "createSmtpTransport(array $config)" function within the laravel MailManager.php file. The output is:
) the output for "composer show winter*" is: winter/storm v1.2.0 Winter CMS Storm Library |
It really doesn't make any sense since |
Apologise for the confusion. My first trace_log() output was from a previous test. If I am reading the data correct in the config object, it is storing the config values from config/mail.php in the root of the object, but the config values from the database are stored further nested in the object under "mailers" and then "smtp". When "createSymfonyTransport()" is called, it only looks for the values on the root of the object. I hope this makes sense, if not, please say and I'll try and explain it differently. |
I understand what you mean, but it doesn't match the behavior I am seeing. Did you completely remove the gmail plugin? Something is screwing with your config dynamically |
Please, can you test this with a CLEAN install with NO PLUGINS installed and report results back? This makes absolutely no sense. |
Tested working on multiple clean install, not a bug. |
Problem caused by the old format used in |
Hi,
Thanks |
Please use the new |
Re, |
@mjauvin is there anything we can do to better support the old config style so no one else runs into this during the upgrade process? |
Marking as a bug due to more confirmations from the community. |
This reverses the order for checking mail configs by searching for the new format first, then checking for the old format. Laravel checks old format first, then new format, which works fine for them, but doesn't work for us as we also populate settings via the Backend, which populates the settings in the new format. Fixes wintercms/winter#626
@bennothommo can this be closed, I see you commited a fix for this. |
The commit is within the open PR, @mjauvin, so this shouldn't be closed yet :) |
This reverses the order for checking mail configs by searching for the new format first, then checking for the old format. Laravel checks old format first, then new format, which works fine for them, but doesn't work for us as we also populate settings via the Backend, which populates the settings in the new format. Fixes wintercms/winter#626
Winter CMS Build
1.2
PHP Version
8.0
Database engine
MySQL/MariaDB
Plugins installed
Winter.Pages, Winter.Blog, Winter.User
Issue description
Since upgrading to Winter 1.2 from the previous version, emailing via SMTP has not worked.
The error message when emailing has always been:
Expected response code "250/251/252" but got code "550", with message "550 5.7.1 Relaying denied".
I've looked into why and I have found that the email settings entered in the Winter backend, saved to the database, are not being used when actually emailing within Winter.
This can be tested by pressing the "Send test message" button in the "Mail configuration" backend section.
Upon looking at the code, when "createSmtpTransport($config)" in MailManager.php from laravel is called, the values it is looking for are $config['host'], $config['username'], $config['password'], $config['port'].
Ref: https://github.com/laravel/framework/blob/8156743f644fb4597b63261a3fda4e4d6ca49a78/src/Illuminate/Mail/MailManager.php#L163-L183
However, when "applyConfigValues()" in MailSetting.php is called, both the values from config/mail.php and the database are combined.
Ref: https://github.com/wintercms/winter/blob/develop/modules/system/models/MailSetting.php#L86-L118
The config values that get passed to laravel are in this format:
Array ( [driver] => smtp [host] => smtp.mailgun.org [port] => 587 [from] => Array ( [address] => mailaddress [name] => Winter CMS ) [encryption] => tls [username] => [password] => [sendmail] => /usr/sbin/sendmail -bs [default] => smtp [mailers] => Array ( [smtp] => Array ( [host] => smtp.office365.com [port] => 587 [username] => mailaddress [password] => password [encryption] => tls ) ) )
It seems that laravel then only uses the config values from config/mail.php instead of the database to make the Smtp connection.
Steps to replicate
Leave the config/mail.php as default from the Winter installation.
Add Smtp settings into the Mail configuration section in the Winter CMS and click on "Send Test email".
Error message "Expected response code "250/251/252" but got code "550", with message "550 5.7.1 Relaying denied"." is then presented.
Workaround
As a temporary workaround, put your Smtp configuration values into config/mail.php.
The text was updated successfully, but these errors were encountered: