Skip to content

Winter 1.2 not using SMTP settings from database #626

@tintong

Description

@tintong

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions