Documentation

Create a new email

First, you need to import EnplatedEmail.php into your project directory according to this instruction.

After the import, you need to initialize the new interface. First, create a variable and call the init function in the EM class.

$emailForm = $EM->init("bgColor1", "bgColor2");

The bgColor1 input variable indicates the background color of the main window, where all text and information will be afterwards generated.

Input variable bgColor2 indicates the color outside the main window. Although it will be replaced by transparent in most email clients, it will work in more modern clients.

Both input variables should be in HEX format (for example, #ffffff or #000000), including the # (number sign) character.

Creating email elements

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.

Adding a logo

To add a logo (typically at the very top of an email), call the following command:

$emailForm = $EM->createLogo($emailForm, "URL");

In the first input variable, we use the variable in which we are currently creating the email - the one we initialized.

In the second input variable URL 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.

Adding text

To create any text, use the following command:

$emailForm = $EM->createText($emailForm, "attribute", "text", "font", "color");

In the first input variable, we use the variable in which we are currently creating the email - the one we initialized.

In the second input variable attribute, 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 third input variable text, 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 fourth input variable font 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 fifth input variable color 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.

Adding text with link

To create a text with link, use the following command:

$emailForm = $EM->createLink($emailForm, "URL", "preText", "linkText", "postText", "font", "color", "linkColor");

In the first input variable, we use the variable in which we are currently creating the email - the one we initialized.

In the second input variable URL we use the URL where we want the link to go. The URL should include the http/ https protocol.

In the third input variable preText we set the text that will be displayed before the link.

In the fourth input variable linkText we set the text of the link itself.

In the fifth input variable postText we set the text that will be displayed after the link.

In the sixth input variable font, 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 seventh input variable color, 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 eighth input variable linkColor, 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.

Adding a button

Buttons are a fast way to, for example, request a user to complete a registration. The implementation is similar to the link:

$emailForm = $EM->createButton($emailForm, "URL", "buttonText", "font", "color", "buttonColor");

In the first input variable, we use the variable in which we are currently creating the email - the one we initialized.

In the second input variable URL we use the URL where we want the button to go. The URL should include the http/ https protocol.

In the third input variable buttonText we set the text of the button itself.

In the fourth input variable font 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 fifth input variable color 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 sixth input variable buttonColor 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.

Adding a separator

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:

$emailForm = $EM->createSeparator($emailForm, "color", height);

In the first input variable, we use the variable in which we are currently creating the email - the one we initialized.

In the second input variable color we use the color in which to display the separator.

In the third input variable height 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.

Adding an empty space

If we want to create a blank space between some elements, we can easily do so with this command:

$emailForm = $EM->createSeparator($emailForm, "color", height);

In the first input variable, we use the variable in which we are currently creating the email - the one we initialized.

In the second input variable color, 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 third input variable height, 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.

Creating a row

When we want to place multiple elements in one row, we must first run the function to switch to row generation:

$emailForm = $EM->createRow($emailForm);

In the first input variable, we use the variablein which we are currently creating the email - the one we initialized.

Next, we add all possible elements as before - but instead to column, they will be aligned next to each other.

Finishing a row

If we want to finish the row generation and resume the standard generation to column, we just use the following command:

$emailForm = $EM->finishRow($emailForm);

In the first input variable, we use the variable in which we are currently creating the email - the one we initialized.

Completing the email and sending it

When we are done with the email and want to prepare it for sending, just use the following command:

$emailForm = $EM->finish($emailForm, messageGen, "font", "color", "linkColor");

In the first input variable, we use the variable in which we are currently creating the email - the one we initialized.

In the second input variable messageGen, we choose whether we want to include a message at the end of the email stating that the Enplated Email service 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 and use, for example, the null instead.

In the third input variable font 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 fourth input variable color 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 fifth input variable, linkColor, 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 an example, let's show the mail function:

mail("name@example.com", "Example emailForm", $emailForm);

You can also view the email via the echo command:

echo $emailForm;

Debug mode

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.

The commands to enable and disable debug can be used freely in the code run and do not need to be bound to a single enable.

Sandbox

A demo-sandbox email can be found on GitHub, where the Enplated Email generation can be better understood.