backdrop-contrib / mimemail

Mime Mail provides functions for other modules to use to send HTML mail.
GNU General Public License v2.0
0 stars 4 forks source link

Mime Mail

This Mime Mail module provides functions that can be used by other modules to accept an HTML message body and header, mime-endcode it and send it via Backdrop's core mail system. It also permits users to receive HTML email.

If the HTML has embedded graphics, these graphics are MIME-encoded and included as a message attachment. It will also send uploaded files as attachments.

Sent messages include your theme's CSS stylesheet files in HTNL messages. When used in conjunction with the module Mail System, Mime Mail will use the designated theme's CSS stylesheets as configured by Mail System. Styles can be converted into inline style attributes with the help of the submodule Mime Mail CSS Compressor.

Site users can choose to receive plaintext emails through a setting in their account profile configuration. The HTML will be converted to plain text and sent as-is. Otherwise, the email will be sent in HTML with a plaintext alternative.

This module provides two custom Rules actions:

Installation

Supplementary modules

There are three submodules:

Help & Documentation

This module may be required by other modules, but in light of the system actions and Rules integration, it can be useful by itself too.

Once installed, any module can send MIME-encoded messages by specifing MimeMailSystem as the responsible mail system for a particular message or all mail sent by one module.

This can be done through the web by installing the module Mail System, and visiting admin/config/system/mailsystem or programmatically as follows:

mailsystem_set(array(
  '{$module}_{$key}' => 'MimeMailSystem', // Just messages with $key sent by $module.
  '{$module}' => 'MimeMailSystem', // All messages sent by $module.
));

You can send email with backdrop_mail() and specify the following optional parameters (5th argument) to build the email and send it:

You can set these in $params either before calling backdrop_mail() or in hook_mail() and of course hook_mail_alter().

Normally, Mime Mail uses email addresses in the form of "name" <address@host.com>, but PHP running on Windows servers requires extra SMTP handling to use this format. If you are running your site on a Windows server and don't have an SMTP solution such as the SMTP module installed, you may need to set the 'Use the simple format of user@example.com for all email addresses' option on the configuration settings page.

This module creates a user preference for receiving plaintext-only messages. This preference will be honored by all messages if the format is not explicitly set and the user has access to edit this preference (allowed by default).

Email messages are formatted using the mimemail-message.tpl.php template. This includes a CSS style sheet and uses an HTML version of the text. The included CSS is either:

If you have installed the module Mail System, you can spedify which theme's CSS to use in "Theme to render rich text emails" at admin/config/system/mailsystem.

Since some email clients (namely Outlook 2007 and GMail) tend to only regard inline CSS, you can use the Mime Mail CSS Compressor submodule to convert CSS styles into inline style attributes. It transmogrifies the HTML source by parsing the CSS and inserting the CSS definitions into tags within the HTML based on the CSS selectors. To use the Compressor, just enable it.

To create a custom mail template copy the mimemail-message.tpl.php file from the mimemail/theme directory into your default theme's folder. Both general and by-mailkey theming can be performed:

NOTE: if you place any of those suggested template files in your theme's templates folder, Mail System will likely ignore the setting "Theme to render rich text emails". Instead, the CSS stylesheets for the current page path theme will be used. This seems to be a bug in Mail System.

When the module Mail System is installed, messages can be rendered using different themes. You can choose the following settings to render the email:

Images with absolute URL will be available as remote content. To embed images into emails you have to use a relative URL or an internal path. Due to security concerns, only files residing in the public file system (e.g sites/default/files) can be used by default.

For example:

The 'send arbitrary files' permission allows you to attach or embed files located outside Backdrop's public files directory. Note that this has security implications: arbitrary means even your settings.php! Give to trusted roles only!

License

This project is GPL v2 software. See the LICENSE.txt file in this directory for complete text.

Current Maintainers for Backdrop

Credits

Port to Backdrop

Maintainers for Drupal:

Acknowledgement

This port to Backdrop would not, of course, be possible without all the work done by the developers and maintainers of the Drupal module.