After the successful implementation of Enplated Email on your site, you can start creating your first email.
Initialize a new email by calling the init function of the EM class.
$EM->init("bgColor1","bgColor2");
The bgColor1 parameter sets the background color of the main window, where all the content is generated.
The bgColor2 parameter sets the color outside the main window. Most email clients replace it with transparency, but some of them use it.
Both parameters should be in HEX format, including the # character (for example, #ffffff or #000000).
By entering the commands listed below, elements will be added to the body of the email one by one.
Elements are added in order - a command called earlier places its element higher in the body of the email.
To add a logo (typically at the very top of an email), call the following command:
$EM->createLogo("url");
The url parameter is the URL of the image file. The file should have a .png, .jpg or .gif extension. Most email clients do not support .svg, so this format is not recommended.
To create text, use the following command:
$EM->createText("attribute", "text", "font", "color");
The attribute parameter is the HTML tag that encloses the text - for example, h1, h2, h3, h4, h5, h6 or p.
The text parameter is the text to display. It can also include PHP variables or HTML tags (strong, i, etc.).
The font parameter sets the font of the text. A sans-serif font is recommended for a clean look and high compatibility, but the choice is entirely up to you.
The color parameter sets the color of the text. Use HEX format, including the # character (for example, #ffffff or #000000).
To create text with a link, use the following command:
$EM->createLink("url", "preText", "linkText", "postText", "font", "color", "linkColor");
The url parameter is the target URL of the link. It should include the http / https protocol.
The preText parameter sets the text displayed before the link.
The linkText parameter sets the text of the link itself.
The postText parameter sets the text displayed after the link.
The font parameter sets the font of the text. A sans-serif font is recommended for a clean look and high compatibility, but the choice is entirely up to you.
The color parameter sets the color of the text before and after the link. Use HEX format, including the # character (for example, #ffffff or #000000).
The linkColor parameter sets the color of the link text. Use HEX format, including the # character (for example, #ffffff or #000000).
Buttons are a great way to, for example, ask a user to complete their registration. The implementation is similar to the link:
$EM->createButton("url", "buttonText", "font", "color", "buttonColor");
The url parameter is the target URL of the button. It should include the http / https protocol.
The buttonText parameter sets the text of the button itself.
The font parameter sets the font of the text. A sans-serif font is recommended for a clean look and high compatibility, but the choice is entirely up to you.
The color parameter sets the color of the button text. Use HEX format, including the # character (for example, #ffffff or #000000).
The buttonColor parameter sets the color of the button. Use HEX format, including the # character (for example, #ffffff or #000000).
Separators (horizontal lines) are a simple way to, for example, separate the main body of an email from the footer:
$EM->createSeparator("color", height);
The color parameter sets the color of the separator.
The height parameter sets the height of the separator in pixels. Do not include the px unit (it is added automatically) or quotation marks. The recommended value is 0.5.
If we want to create a blank space between some elements, we can easily do so with this command:
$EM->createSpace(height, "color");
The color parameter is the background color (the same color as the first parameter of init). This option may seem unnecessary, but some email clients require it. Use HEX format, including the # character (for example, #ffffff or #000000).
The height parameter sets the height of the space in pixels. Do not include the px unit (it is added automatically) or quotation marks.
An important part of an email can be multiple elements placed next to each other - multiple buttons or links, for example.
By default, Enplated Email generates all elements underneath each other. However, you can change this setting using the switches below.
When we want to place multiple elements in one row, we must first run the function to switch to row generation:
$EM->createRow();
Next, add elements as before - but instead of a column, they will be aligned next to each other.
To finish the row and return to the standard column layout, use the following command:
$EM->finishRow();
When the email is ready to be sent, use the following command:
$emailForm = $EM->finish(messageGen, "font", "color", "linkColor");
The messageGen parameter decides whether to add a message at the end of the email stating that it was generated with Enplated Email. The message also includes a link for reporting errors. Allowed values are true (the message is displayed) and false (the message is not displayed). Thank you for keeping the message on. ❤️
If you have decided not to display the message, you can skip the following parameters.
The font parameter sets the font of the text. A sans-serif font is recommended for a clean look and high compatibility, but the choice is entirely up to you.
The color parameter sets the color of the message text. Use HEX format, including the # character (for example, #ffffff or #000000).
The linkColor parameter sets the color of the link in the message. Use HEX format, including the # character (for example, #ffffff or #000000).
Now you can send your email. For example, with the mail function:
mail("name@example.com", "Example emailForm", $emailForm);
You can also view the email with the echo command:
echo $emailForm;
The HTML code of the email can also be accessed with this command:
$EM->html;
Enplated Email has a built-in debug mode.
If you want to list what Enplated Email is currently doing, for example to find an error, use the following command:
$EM->debugAllow();
To disable debug mode, use this command:
$EM->debugDisable();
The debug output is printed with the echo command.
A demo sandbox email is available on GitHub, to help you better understand how Enplated Email works.