Configuring per-user email preferences

Last updated on
11 March 2021

This documentation needs work. See "Help improve this page" in the sidebar.

Needs work. For now this is just a copy of the issue summary that added this feature ...

The way this feature works in D7

Enable Mime Mail.

Mime Mail defines a hook_form_FORM_ID_alter() to alter the User edit page - this is the page you see when you log on, go to /user, then select the 'Edit' tab.

This hook puts a checkbox on every user's edit page, giving each user a choice to have plaintext email or not. It looks like this:
D7 plaintext settings

While this feature is nice, it did not give the site builder much flexibility in when, where, and how this selection checkbox was presented. Installing Mime Mail always added this checkbox, whether or not the site builder wanted it. And in fact, site builders have to do extra work to remove this checkbox if they don't want to use this feature, or if they want to present the choice in a different place or with a different explanation.

This feature in D7 also did not play well with other modules that sent email without using Mime Mail - even with this box checked a user could still receive HTML email because a site can be configured to use other modules for formatting and sending some subset of email. So this user preference was not always respected.

The way this feature works in D8

IF the site builder wants this feature, then:

Site builder goes to the account settings at /admin/config/people/accounts and clicks on the "Manage Fields" tab (or, can go directly to /admin/config/people/accounts/fields)

Site builder adds a single-value boolean field to the account settings. It can be worded however you like, and can have any default value you like, and can be named anything you like - the important part is that when this value is set to TRUE, the user will only receive plaintext email.

Site builder goes to the "Manage display" and the "Manage form display" tabs to configure where, when, and how this field appears on the user page, including whether a checkbox, radio buttons is used to change the value.

Site builder goes to Mime Mail settings form at /admin/config/system/mimemail, chooses the field that was created above, then saves the settings.

Mime Mail will now respect that per-user setting.

As you can see, the site builder may make this look just like the D7 implementation, but the point is it doesn't HAVE to - it's much more flexible now.
D8 plaintext settings

Help improve this page

Page status: Needs work

You can: