?
avatar PhilETaylor
PhilETaylor
8 Jan 2021

Steps to reproduce the issue

Install Joomla 4b6
in admin -> System -> Mail Templates -> Options -> set Mail Format = Both
Go to Joomla Global Config
Click Test Mail

Expected result

An email is sent with php mail.

Actual result

scroll up and see message:

Screenshot 2021-01-08 at 21 29 14

System information (as much as possible)

Additional comments

avatar PhilETaylor PhilETaylor - open - 8 Jan 2021
avatar joomla-cms-bot joomla-cms-bot - change - 8 Jan 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 8 Jan 2021
avatar HLeithner
HLeithner - comment - 8 Jan 2021

@Hackwar can you have a lock at this please?

avatar wilsonge wilsonge - change - 10 Jan 2021
Labels Added: ?
avatar wilsonge wilsonge - labeled - 10 Jan 2021
avatar Fedik
Fedik - comment - 16 Jan 2021

Same error if set Mail Format to "HTML".

The reason that there no HTML template, for the test message, for com_config.test_mail.
Same error will be for all emails without HTML template, in administrator/index.php?option=com_mails&view=templates,
And vice versa, when Mail Format to "plaintext" but email template for "plaintext" is empty.

I guess we need some kind of fallback in Joomla\CMS\Mail\MailTemplate, something to:

// Html fallback from plaintext
if (!$mail->htmlbody && $mail->body)
{
  $mail->htmlbody = nl2br($mail->body)
}

// Plaintext fallback from HTML
if (!$mail->body && $mail->htmlbody)
{
  $mail->body = strip_tags(str_replace(['<br>', '<br />'], "\n", $mail->htmlbody));
}

This will work if one of template is missing, and fail when both templates is empty (that is okay).

@Hackwar what do you think? I can try to make a PR

avatar Hackwar
Hackwar - comment - 22 Jan 2021

@Fedik If you have the time, please be my guest. It would be greatly appreciated. I'm currently struggling to get stuff like this done.

avatar Fedik
Fedik - comment - 23 Jan 2021

please test #32118

avatar alikon alikon - change - 23 Jan 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-01-23 10:07:42
Closed_By alikon
avatar alikon alikon - close - 23 Jan 2021
avatar wilsonge wilsonge - change - 20 Feb 2021
Labels Removed: ?
avatar wilsonge wilsonge - unlabeled - 20 Feb 2021

Add a Comment

Login with GitHub to post a comment