Last Modified: 03.09.2021
Email templates are located at the page Settings > System Settings > Email and SMS events > E-mail templates. To edit an email template, select the item Edit option in the required action menu:
for the email template. The majority of parameter names are self-explanatory, including:
- From - a web address, indicated as email sender e-mail.
- To -
Addresses are separated via comma.
for email recipients.
Note: When From and To fields are empty without specific email URLs - default URLs are indicated instead. System sources URL (with associated template) from site settings and then, if such address is not found, sources from Main module. Because the URL in both cases is the same, it will be indicated in both fields.
- Bcc - blind carbon copy won't be visible for neither main recipient, nor recipients from Carbon Copy (CC): field. Additionally, recipients from Bcc field also won't see each other in email recipients.
- Priority - click on the pointer and indicate the High-Medium-Low degree of dispatched notification.
- Subject - indicate email subject. This field is convenient for specific themed-email campaigns. Such subject must be created preliminarily.
The message itself is stipulated in the Message body window. When editing the message, select the most convenient message format: Text, HTML or Visual editor.
Available field values for message parameters and body can be indicated below as macros:
In addition to macros, email templates can contain PHP code (starting from main module version 15.0.7). For example:
Your login: #LOGIN#
Current date: <?=date('d.m.Y')?>
Note: In majority of cases, main module setting parameters are indicated.
Clicking on Add template opens a form identical to template edit form where you need to attach a template to previously created email event:
To view all firm fields, click show additional headers....
Email templates allows
Starting from main module version 15.0.7.
in the visual editor. However, the following must be considered:
- Component connecting is performed by the method
EventMessageThemeCompiler::includeComponent() instead of the method
Method connects component 2.0. Non-static method.
, arguments, passed by the new method similar to arguments
- Visual editor shows only mail components with type
"TYPE" => "mail" specified in the description file (.description.php) when editing an email template. For example:
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
$arComponentDescription = array(
"NAME" => GetMessage("SBBS_DEFAULT_TEMPLATE_NAME"),
"TYPE" => "mail",
"DESCRIPTION" => GetMessage("SBBS_DEFAULT_TEMPLATE_DESCRIPTION"),
"ICON" => "/images/sale_basket.gif",
"PATH" => array(
"ID" => "e-store",
"CHILD" => array(
"ID" => "sale_basket",
"NAME" => GetMessage("SBBS_NAME")
Without it, the component can be connected only manually by inserting a query call.
- Component that is connected in the email template can be executed on a hit (sending an email). Accordingly component shouldn't use:
- global object
CUser class global object, stores authentication data for current user; intended for customizing current user parameters.
, containing data on hit source, but not the email recipient;
Current site ID when using Public section, language ID when using in Administrative section.
In case of public section, this constant stores "Language" field from current site. In case of admin section, this constant stores current language ID.
Current site template ID.
Instead, use the following method calls:
$this->getSiteId() - site, specified in the email event,
$this->getLanguageId() - site language, specified in email event,
$this->getSiteTemplateId() - site template, specified in the email template.
When sending email by template, the system executes component code. Language files in the component will be connected for the language, indicated in the settings of the site specified in the email event. Email uses the same encoding, as indicated in site settings, passed in email event.
Message subject - is the message subject template. It is created from subject list at the page Settings > System Settings > Email and SMS events > E-mail templates . The procedure is similar to
Design template - is a site external appearance that defines location of various elements at the website, art style and page display method. Enables html- and php-code, graphic elements, style tables, additional files for content display. Can enable component templates, finished page templates and snippets.
and has similar structure. Technically, visual theme - is a site template in the folder
/bitrix/templates. When creating a specific theme for email messages, select the value E-mail template in the Type field. In this case, the description file (.description.php) will contain the type
"TYPE" => "mail":
<?$arTemplate = array(
"NAME" => "Test visual theme",
"DESCRIPTION" => "Test visual theme",
"SORT" => "",
"TYPE" => "mail",
Styles, specified in style files will be inserted into an email (inline) at the call location:
Message subjects, as well as site template can contain PHP code.
Search of E-mail component template is executed by standard algorithm. When e-mail template with connected component has an indicated visual theme, the visual theme folder is used as a current site template when searching component template.