Replace the default html template by one made with [Foundation Emails] (http://foundation.zurb.com/emails/docs/css-guide.html).
The email templates use zurb/foundation-emails (v 2.2.1) to provide a consistent markup.
The generic email comes with a few new options:
If you define a Callout, it will be displated as a callout
If you define a Sidebar, a right sidebar will be displayed (ratio 7/5)
If you define a HeroImage (an Image object), it will be displayed below the body and before the callout
$email = new Email();
'EmailContent' => 'Here is my body',
'Callout' => 'Here is my callout',
'Sidebar' => 'Here is my sidebar',
'HeroImage' => Image::get()->first()
A default Header and Footer is provided:
In the footer, social medias links should be provided through the EmailFooterLinks method
on the SiteConfig. Each item consist of a : Class, Link, Label and Icon.
NOTE: do not use setBody because it will prevent the usage of the default template.
Instead, rely on addData(['EmailContent' => $body]).
Instead of relying on specific markup, you can also use template helpers directly
in your email templates. For instance:
$email = new Email(); $viewer = new SSViewer('MyEmailTemplate'); $result = $viewer->process($this); $email->addData(['EmailContent' => (string) $result]); Dear Customer,<br/><br/> Please find your password reset link:<br/><br/> $FoundationButton('Reset your passowrd', $PasswordResetLink)
Available helpers are:
The templates are divided in various include which allow you to easily make them
fit your styles.
To define your base styles, override FoundationEmailStyles.ss.
To define your own headers and footers, override FoundationEmailFooter and FoundationEmailHeader.
Two other styles are provided : "vision" and "ceej". Feel free to use the one you like the most.
You can select your theme by applying the following config.
FoundationEmails: theme: 'vision'
You can also edit basic color or use extension point "updateFoundationColors".
FoundationEmails: colors: HeaderBg: '#333' Header: '#fff' Link: '#2199e8' Background : '#f3f3f3' CalloutBg : '#ddd' Callout : '#ddd' BtnBg : '#333' Btn : '#fff'
These default templates have been overriden.
NOTE : we include a button to reset the password instead of a plain link.
As explained in the [SilverStripe documentation] (https://docs.silverstripe.org/en/4/developer_guides/email/) you can create
subclasses of the Email class.
An example class has been provided called WelcomeEmail.
For your convenience, a task called "Email Viewer Task" has been provided.
This task allow you to select any subclass of the Email class and see its html (preview and code).
You can also set the locale and inline styles (require pelago/emogrifier) for better testing.
If your emails require constructor arguments that are DataObjects, random records
from your database will be injected. If you want to inject specific records, pass
ClassNameID=YourID as GET parameters (for instance MemberID=5).
Tested with 4.1+
LeKoala - [email protected]
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem