After the successful implementation of Enplated Email into your site, you can start creating your first email.
Initialize the new interface with calling the init function in the EM class.
$EM->init("bgColor1","bgColor2");
The bgColor1 input variable set the background color of the main window, where all text and information will be afterwards generated.
The bgColor2 input variable set the color outside the main window. Although it will be replaced by transparent in most email clients, some of them will use it.
Both input variables should be in HEX format (for example, #ffffff or #000000), including the # (number sign) character.
By entering the commands listed below, elements will be added to the body of the email one by one.
Adding works in a stack style - the command called earlier will create the text that will be placed 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");
In the url input variable we use the URL link to the image file. The file should have a .png, .jpg or .gif extension. Most email clients do not support the .svg format, so it is not recommended to use this format.
To create text, use the following command:
$EM->createText("attribute", "text", "font", "color");
In the attribute input variable, we use the HTML tag in which we want the text to be enclosed - for example, h1, h2, h3, h4, h5, h6, or p.
In the text input variable, we use the actual text we want to display. Of course, PHP variables or HTML tags (strong, i, etc.) can also be included here.
In the font input variable we use the font in which the text will be displayed. For a nice design and high compatibility it is recommended to use for example a sans-serif font, but of course the choice is entirely up to you.
In the color input variable we use the color we want the text to be displayed in. It should be in HEX format (for example, #ffffff or #000000) including the # (number sign) character.
To create a text with link, use the following command:
$EM->createLink("url", "preText", "linkText", "postText", "font", "color", "linkColor");
In the url input variable we use the URL where we want the link to go. The URL should include the http/ https protocol.
In the preText input variable we set the text that will be displayed before the link.
In the linkText input variable we set the text of the link itself.
In the postText input variable we set the text that will be displayed after the link.
In the font input variable, we use the font in which the text will be displayed. For a nice design and high compatibility it is recommended to use for example a sans-serif font, but of course the choice is entirely up to you.
In the color input variable, we use the color we want the text before and after the link to be displayed in. It should be in HEX format (for example, #ffffff or #000000) including the # (number sign) character.
In the linkColor input variable, we use the color we want the link text to appear in. It should be in HEX format (for example, #ffffff or #000000) including the # (number sign) character.
Buttons are a great way to, for example, request a user to complete a registration. The implementation is similar to the link:
$EM->createButton("url", "buttonText", "font", "color", "buttonColor");
In the url input variable we use the URL where we want the button to go. The URL should include the http/ https protocol.
In the buttonText input variable we set the text of the button itself.
In the font input variable we use the font in which the text will be displayed. For a nice design and high compatibility it is recommended to use for example a sans-serif font, but of course the choice is entirely up to you.
In the color input variable we use the color in which we want to display the link text. It should be in HEX format (for example, #ffffff or #000000) including the # (number sign) character.
In the buttonColor input variable we use the color in which we want to display the button color. It should be in HEX format (for example, #ffffff or #000000) including the # (number sign) character.
Separators (horizontal lines) are a simple way to, for example, end the main body of an email and follow it with the footer. It is very simple to use:
$EM->createSeparator("color", height);
In the color input variable we use the color in which to display the separator.
In the height input variable we use the height of the separator. This is specified in pixels, but we do not enter the px unit into the variable (it is added automatically). The number is also given without quotes / apostrophes. 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->createSeparator("color", height);
In the color input variable, we use the background color (the same color as the first input variable when initializing). While this option may seem like an unnecessary one, it is required in some email clients. It should be in HEX format (for example, #ffffff or #000000) including the # (number sign) character.
In the height input variable, we use the height of the space. This is specified in pixels, but we do not enter the px unit into the variable (it is supplied automatically). The number is also given without quotation marks/apostrophes.
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, we add all possible elements as before - but instead to column, they will be aligned next to each other.
If we want to finish the row generation and resume the standard generation to column, we just use the following command:
$EM->finishRow();
When we are done with the email and want to prepare it for sending, just use the following command:
$emailForm = $EM->finish(messageGen, "font", "color", "linkColor");
In the messageGen input variable, we choose whether we want to include a message at the end of the email stating that the Enplated Email was used to generate the email. A link will also be added here to report any errors. The allowed values are true (the message will be displayed) and false (the message will not be displayed). Thank you very much for possibly displaying the message.❤️
If you have decided not to display the message, you can skip the following variables.
In the font input variable we use the font in which the text will be displayed. For a nice design and high compatibility it is recommended to use for example a sans-serif font, but of course the choice is entirely up to you.
In the color input variable we use the color in which we want the text stating that Enplated Email has been used to be displayed. It should be in HEX format (for example, #ffffff or #000000) including the # (number sign) character.
In the linkColor, input variable we use the color we want the link text to display that Enplated Email has been used. It should be in HEX format (for example, #ffffff or #000000) including the # (number sign) character.
Now you can send your email. For example, with a mail function:
mail("name@example.com", "Example emailForm", $emailForm);
You can also view the email via the echo command:
echo $emailForm;
HTML code of the email can be also be accessed with this command:
$EM->html;
Enplated Email has a built-in debug mode that can be activated by calling the following command:
In case you want to start listing what Enplated Email is currently doing to find a possible error, you can use the following command:
$EM->debugAllow();
In the case where you want to disable debug mode, you can do so with this command:
$EM->debugDisable();
The debug output will be served by the echo command.
A demo-sandbox email can be found on GitHub, where the Enplated Email generation can be better understood.