WireMailBranding by martijn-geerts

Add a wrapper around bodyHTML.

WireMailBranding

Add email templates to wireMail

How it works?

Create an email template without content. On the spot where you wish to have your content place the tag {bodyHTML}. The markup you've set with $mail->bodyHTML('<p>Markup</p>'); will replace that tag.

Setting the defaults

Go to the module settings and set the path to your email template. Make sure it is an absolute URL. Optionally you could inline all CSS with Emogrifier when you add a CSS file. The CSS file needs to be placed in the same folder, have the same basename as the wrapper and should end with the .css extension.

When using the Emogrifier CSS inliner applying it on the bodyHTML only is the most efficient way. We recommend you to write the inline styles for the wrapper manually.

Overwriting the defaults

The API overwrites the settings set in the module configuration.

$mail = wireMail();
$mail->to('user@some-domain.ext')->from('you@own-domain.ext');
$mail->subject('Mail Subject');

// Overwrite the Absolute URL
$mail->template('/site/templates/template_wrapper.php');

// Overwrite the Emogrifier CSS inliner. (0, bodyHTML, wrapper)
$mail->inlineCSS('bodyHTML');

$mail->bodyHTML('<p>This paragraph will replace the {bodyHTML} tag in the mail template.</p>');
$mail->send();

The added methods

// Disable the wrapper template* (Just send the bodyHTML)
$mail->template('');

// Disable the Emogrifier inliner
$mail->inlineCSS(0);

// Apply only on bodyHTML. (optimal when using Emogrifier inliner)
$mail->inlineCSS('bodyHTML');

// Apply over the complete HTML.
$mail->inlineCSS('wrapper');

Thanks!

This module is written by Martijn Geerts and sponsored by Calago.nl.

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #559
    The 559th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 25 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK