Built a custom module to check when content for a particular node type is updated.  It sends an email to a user, letting them know what was updated.  It is sending the email to the user as intended but not as an HTML email, the HTML tags are displayed in the email.  We have the Mail System and Mime Mail modules installed and it is set to send emails as Full HTML.  We even tested adding HTML headers and body tags in the module where the email was being out together but it continues to send as plain text.  Any suggestions?

Comments

Mail system and Mime Mail should do the trick. Can you post photos of the configuration pages for both modules? 

Also, notice that there is a bug in Backdrop that is fixed in the next version (1.30.0). Without that fix, all HTML emails sent using the default mail system in Backdrop and PHP 8.1+ will show the tags. Try using the current dev version of Backdrop or wait until the preview release is done in a couple of days. Or use PHP 7.4

 

So, these are the configs that work for me:

 

In Mail System, notice that I have "Mime Mail" as Delivery AND Formatting. Mime Mail already fixed the bug that's getting fixed in Backdrop 1.30.0, so if you have this like shown below,  the HTML email should work.

This is the configuration for Mail System:

Notice the email format: I must be Raw HTML so that the tags don't get double-escaped.

 

And Mime Mail:

(we have same Sender Name & Sender email but no option for Raw HTML)

I can select the "Use simple address format" but "Include site style sheets" is grayed out

I think we are on the most recent versions:

 

 

 

 

Hmm... this is strange. Try disabling Mime Mail CSS Compressor. 

What PHP version are you using for the site?

Can you also open the file mimemail.settings.json from your active config folder (typically at files/confix_XXX/active) and check that there is a value for mimemail_headers_crlf? That should be "\r\n".


 

Another question: how are you building the text in the body being sent?  Perhaps that's where the double-escaping is happening. Typically you want to do something like this:

$message['body'] = check_markup(YOUR_TEXT_WITH_TAGS, config_get('mimemail.settings', 'mimemail_format'));

If you are passing the text through check_plain() then you'll end up with escaped tags (HTML entities), which will be included in your email as un-rendered tags. 

EDIT: actually, the check_markup() will be done by the MimeMail formatter - you don't need to do that. Simply pass the unfiltered text with tags in $message['body']. Do not pass the text through check_plain() as this will double-escape the text (if you are worried about sanitization, the body will be sanitized by MimeMail before being sent using the text format you selected for MimeMail).