php.ini
and set
[mail function]
sendmail_path=/usr/local/foobar
A test email is sent using the Global Configuration settings.
Error message:
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
It really doesn't matter because it's a verifiable bug.
When the alternative_mailconfig
of the com_mails
component is set to 1 (“Per Template Mail Settings” is set to Yes) the Joomla\CMS\Mail\MailTemplate::send()
method ALWAYS tries to use the mail template's mailer settings even if you have set the mail template's “Mail Settings” option to No. This happens because the only condition check is
if ($config->get('alternative_mailconfig'))
This problem has existed since the Mail Templates component was first introduced in Joomla 4.0 on September 28th, 2019 with PR #22126. In fact, the alternative_mailconfig
option in the mail template itself has never worked at all ever since the feature was contributed.
There should really be TWO checks there. Off the top of my head:
if ($config->get('alternative_mailconfig') && (int) ($params->get('alternative_mailconfig', 0) === 1)
Further to that, the administrator/components/com_mails/forms/template.xml
file should have a default value of 0 (not 1!) for alternative_mailconfig
.
Moreover, the rest of the code in MailTemplate::send dealing with the custom mailer settings is wrong. For example, $smtpuser = $params->get('smtpuser', $app->get('smtpuser'));
will always return the email template's setting for smtpuser
even if that's left empty. Defaulting to the application's global configuration parameter will never happen since Joomla never does store NULL for empty string fields, it stores an empty string which does NOT trigger the Registry's default return in get(). That's why saving a mail template with no mailer configuration currently doesn't use the Global Configuration and how I ultimately found out about this bug.
If someone else could confirm the issue I will make a PR against 4.1 addressing all three issues.
BTW, is any other 3PD using this feature or am I the only one...? It beggars belief that I am the first one to notice this fairly obvious problem after three years of that code being in the core. Huh.
Labels |
Added:
No Code Attached Yet
|
Thank you for the confirmation! Now there are three of us who experienced it I am calling it a bug. I will come back with a PR shortly. Once again, thank you!
Opened pull request #37948.
@Kostelano Could you please give it a quick test?
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-05-31 20:56:42 |
Closed_By | ⇒ | richard67 |
Closing as having a pull request.
I can confirm that according to the instructions we get an error. True, I got another error without making changes to php.ini.
SMTP Error: Could not connect to SMTP host.