2017 © Pedro Peláez
 

silverstripe-module silverstripe-email-helpers

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

image

markguinn/silverstripe-email-helpers

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  • Wednesday, March 22, 2017
  • by markguinn
  • Repository
  • 5 Watchers
  • 28 Stars
  • 26,140 Installations
  • PHP
  • 6 Dependents
  • 1 Suggesters
  • 14 Forks
  • 11 Open issues
  • 9 Versions
  • 6 % Grown

The README.md

SilverStripe Email Helpers

Build Status, (*1)

Contains replacement Mailer object that utilizes PHPMailer to send e-mail via SMTP instead of php's mail() function. Optionally, TLS can be enabled for secure communication with the SMTP server and a charset for the e-mail encoding can be specified. In addition, embedded CSS, plus a specified external CSS file, can be inlined into the email's HTML., (*2)

Also includes a drop-in replacement for the Email class called StyledHtmlEmail. If used with HTML emails it allows you to include a style section at the top of the email which will then be inlined as style attributes on the actual html tags to promote better compatibility across email clients., (*3)

Requirements

Silverstripe 3.0+, (*4)

Installation

Install via composer:, (*5)

composer require markguinn/silverstripe-email-helpers:dev-master

This module installs PHPMailer and Emogrifier: - https://github.com/PHPMailer/PHPMailer - https://github.com/MyIntervals/emogrifier, (*6)

Usage

SMTP Mailer

To use the SMTP mailer add the following code to your _config.php:, (*7)

$encryption = 'tls'; // use tls
$charset = 'UTF-8'; // use specified charset if set
// you can specify a port as in 'yourserver.com:587'
$mailer = new SmtpMailer('yourserver.com', 'username', 'password', $encryption, $charset);
Email::set_mailer($mailer);  // or Injector::inst()->registerService($mailer, 'Mailer');

Alternatively, any of these can be set using the config system like so:, (*8)

SmtpMailer:
  host: yourserver.com
  user: username
  password: password
  encryption: tls
  charset: UTF-8

And then in _config.php:, (*9)

Email::set_mailer( new SmtpMailer() );

Emogrified Smtp Mailer

If you wish to embed CSS into your email's HTML then use the EmogrifiedSmtpMailer class. Add the following code to your _config.php:, (*10)

$encryption = 'ssl'; // use ssl
$charset = 'UTF-8';
$externalcssfile = 'themes/{yourtheme}/css/externalcssfile.css';  // specify the path to your css file
$SMTPDebug = 2;  // Levels 0-4 available
$logfailedemail = true;  // Log a notice with PHPMailer's error information
$mailer = new EmogrifiedSmtpMailer('yourserver.com', 'username', 'password', $encryption, $charset, $externalcssfile, $SMTPDebug, $logfailedemail);
Email::set_mailer($mailer);  // or Injector::inst()->registerService($mailer, 'Mailer');

Alternatively, any of these can be set using the config system like so:, (*11)

EmogrifiedSmtpMailer:
  host: yourserver.com
  user: username
  password: password
  encryption: ssl
  charset: UTF-8
  cssfile: 'themes/{yourtheme}/css/externalcssfile.css'
  SMTPDebug: 2
  logfailedemail: true

And then in _config.php:, (*12)

Email::set_mailer( new EmogrifiedSmtpMailer() );

Styled Html Email

To use the styled email, just literally use the StyledHtmlEmail class where you'd normally use the Email class and add a single style tag in the body of the email. For example:, (*13)

<style type="text/css">
.bigred {
    color: red;
    font-size: 30px;
}
</style>
Hello <span class="bigred">CUSTOMERS</span>.

Would be sent as:, (*14)

Hello <span style="color:red; font-size:30px">CUSTOMERS</span>.

The Versions

22/03 2017

dev-master

9999999-dev

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  Sources   Download

The Requires

 

The Development Requires

email silverstripe smtp emogrifier

22/03 2017

1.3.2

1.3.2.0

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  Sources   Download

The Requires

 

The Development Requires

email silverstripe smtp emogrifier

27/02 2017

1.3.1

1.3.1.0

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  Sources   Download

The Requires

 

The Development Requires

email silverstripe smtp emogrifier

13/05 2016

1.3.0

1.3.0.0

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  Sources   Download

The Requires

 

The Development Requires

email silverstripe smtp emogrifier

21/04 2016

1.2.1

1.2.1.0

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  Sources   Download

The Requires

 

The Development Requires

email silverstripe smtp emogrifier

02/03 2016

1.2.0

1.2.0.0

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  Sources   Download

The Requires

 

The Development Requires

email silverstripe smtp emogrifier

31/07 2014

1.1.0

1.1.0.0

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  Sources   Download

The Requires

 

email silverstripe smtp emogrifier

31/07 2014

dev-bundled-dependencies

dev-bundled-dependencies

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  Sources   Download

The Requires

 

email silverstripe smtp emogrifier

05/03 2013

1.0.0

1.0.0.0

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

  Sources   Download

The Requires

 

email silverstripe smtp emogrifier