? ? Success

User tests: Successful: Unsuccessful:

avatar nonumber
nonumber
28 Mar 2016

This creates the ability to make the User component send HTML emails instead of plain text.

We can override the registration and activation email bodies via the language overrides. However, any html markup does not work in the current Joomla release.

This PR adds a Send As HTML option in the Users global configuration to allow html in these email bodies:
image

Backwards Compatibility

When you switch the Send As HTML on, all emails not using html will still work.
The plain text email bodies use \n for new lines. These will be converted to <br /> tags (if no other html closing tags are found).

Testing instructions

To test this, create a language override for one of these language strings (depending on your settings):

COM_USERS_EMAIL_REGISTERED_BODY
COM_USERS_EMAIL_REGISTERED_BODY_NOPW
COM_USERS_EMAIL_REGISTERED_NOTIFICATION_TO_ADMIN_BODY
COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY
COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY_NOPW
COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY
COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY_NOPW

In this example I am using the settings: New User Account Activation: Self and Send Password: No.
So the language string to use is: COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY_NOPW

So you can create a language override for this string with:

<div style="background-color: #ededed; border: 1px solid #ddd; padding: 12px;"><h2>Your user account needs activating</h2><p>Hello [[%1:name%]],</p><p>Thank you for registering at [[%2:sitename%]].</p><p>Your account has been created and must be activated before you can use it.<br>To activate the account select the following link or copy-paste it in your browser:<br>[[%3:url%]]</p><p>You have registered on our site using the username <strong>[[%5:username%]]</strong>.</p></div><p style="font-size: small; color: #999; text-align: center;">You are receiving this automatic email message because you have registered at [[%2:sitename%]].</p>

Or add this directly to your en-GB.override.ini

COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY_NOPW="<div style="_QQ_"background-color: #ededed; border: 1px solid #ddd; padding: 12px;"_QQ_"><h2>Your user account needs activating</h2><p>Hello [[%1:name%]],</p><p>Thank you for registering at [[%2:sitename%]].</p><p>Your account has been created and must be activated before you can use it.<br>To activate the account select the following link or copy-paste it in your browser:<br>[[%3:url%]]</p><p>You have registered on our site using the username <strong>[[%5:username%]]</strong>.</p></div><p style="_QQ_"font-size: small; color: #999; text-align: center;"_QQ_">You are receiving this automatic email message because you have registered at [[%2:sitename%]].</p>"

The resulting email will look like:
image

avatar nonumber nonumber - open - 28 Mar 2016
avatar nonumber nonumber - change - 28 Mar 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 28 Mar 2016
Labels Added: ? ?
avatar brianteeman brianteeman - change - 28 Mar 2016
Labels
avatar brianteeman brianteeman - change - 28 Mar 2016
Category Components Feature Request
avatar nonumber nonumber - change - 28 Mar 2016
Labels
avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Mar 2016

Shouldn't this be a system wide setting in com_config instead of being just for users component?

Also, IMHO, an HTML mail should also send an alternative text version, i.e., AltBody (alternative body), for mail readers that don't accept HTML.
More info https://github.com/PHPMailer/PHPMailer/blob/master/class.phpmailer.php#L111-L118

avatar nonumber
nonumber - comment - 28 Mar 2016

Do you know any mail readers that are used in 2016 that don't support HTML?

avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Mar 2016

No, but some are configured to block it.

BTW i think this is a nice improvement!

avatar nonumber
nonumber - comment - 28 Mar 2016

That would be a discussion outside the scope of this PR addition.
The admin is free to not switch on this option.
The Joomla core sendMail() method is used by many extensions (and core) to send html emails. It does not have the ability to also send a non-html alt body.

Also, making this 'Send as HTML' a global option would be a major task and could cause issues with other components. This needs to be set on a component/extension level, IMO.

avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Mar 2016

That would be a discussion outside the scope of this.
The admin is free to not switch on this option.
The Joomla core sendMail() method is used by many extensions (and core) to send html emails. It does not have the ability to also send a non-html alt body.

ok i see.

Also, making this 'Send as HTML' a global option would be a major task and could cause issues with other components. This needs to be set on a component/extension level, IMO.

yes, it would be a major task.

avatar brianteeman
brianteeman - comment - 28 Mar 2016

I would consider it bad practice to allow the sending of html only emails
without a plain text alternative and should not be encouraged. Both gmail
and outlook.com will typically mark an html only email as spam

In addition just one imperfect html tag and your guaranteed to go the spam
box

On 28 March 2016 at 14:00, Peter van Westen notifications@github.com
wrote:

That would be a discussion outside the scope of this.
The admin is free to not switch on this option.
The Joomla core sendMail() method is used by many extensions (and core)
to send html emails. It does not have the ability to also send a non-html
alt body.

Also, making this 'Send as HTML' a global option would be a major task and
could cause issues with other components. This needs to be set on a
component/extension level, IMO.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#9634 (comment)

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

avatar nonumber
nonumber - comment - 28 Mar 2016

Then why do we have a Send in HTML Mode setting in the core com_users Mass Mail view?
image

avatar brianteeman
brianteeman - comment - 28 Mar 2016

No idea ;)

"Just because you can doesnt mean you should

avatar nonumber
nonumber - comment - 28 Mar 2016

Same can be said about this PR.
Leave the 'should I?' to the website administrator.

avatar nonumber
nonumber - comment - 28 Mar 2016

Sorry I tried.

I forgot that the only way to get something useful done for me is to concentrate on extensions. And not bother with core.

Coling this. If someone else wants to drag this uphill, be my guest.

avatar nonumber nonumber - change - 28 Mar 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-03-28 13:37:54
Closed_By nonumber

Add a Comment

Login with GitHub to post a comment