Documentation

Email system

Description

E-mail system is technology designed for handling e-mail messages on site.

Working with the mail system consists of the following stages:

  1. Creating an email event type. Type of mail event can be created using the function CEventType::Add, or at the page for E-mail event types.
  2. Creating an email template. Available in the admin section "Email Templates" menu, as well as via the function CEventMessage::Add.
  3. Creating an email event. Email event can be created only via function CEvent::Send.

The system calls the function CEvent::CheckEvents automatically at the end of each page, with main objectives as follows:

  1. select from the table b_event the unprocessed email events
  2. generate email messages (email) for them
  3. send them
  4. write the result into the table b_event into the field SUCCESS_EXEC, using one of the following designations:
    • Y - all emails as per all email templates were sent successfully
    • F - all emails as per all email templates failed to be sent
    • P - portion of emails were sent successfully, another portion of emails - successfully
    • 0 - email template weren't found
    • N - email event hasn't been processed yet by the function CEvent::CheckEvents

Email campaign can be modified by updating the following kernel module settings:

In addition to the abovelisted parameters, the constant ONLY_EMAIL is also available: initializing it allows sending all emails only to the specified address or group of addresses.

Example of mail event type

<?
$obEventType = new CEventType;
$obEventType->Add(array(
    "EVENT_NAME"    => "ADV_BANNER_STATUS_CHANGE",
    "NAME"          => "banner status updated",
    "LID"           => "com",
    "DESCRIPTION"   => "
        #ID# - banner ID
        #CONTRACT_ID# - contract ID
        #TYPE_SID# - type ID
        "
    ));
?>

Example of mail event

<?
$arr["ACTIVE"]      = "Y";
$arr["EVENT_NAME"]  = "ADV_BANNER_STATUS_CHANGE";
$arr["LID"]         = array("com","de");
$arr["EMAIL_FROM"]  = "admin@site.com";
$arr["EMAIL_TO"]    = "admin@site.com";
$arr["BCC"]         = "";
$arr["SUBJECT"]     = "Updated status for banner #ID#";
$arr["BODY_TYPE"]   = "text";
$arr["MESSAGE"]     = "
Attention! Banner status # #ID# updated.
Banner type - #TYPE_SID#
Contract ID - #CONTRACT_ID#
";
$obTemplate = new CEventMessage;
$obTemplate->Add($arr);
?>

Example of mail event

<?
$arFields = array(
    "ID"          => 124,
    "CONTRACT_ID" => 1,
    "TYPE_SID"    => "LEFT"
    );
CEvent::Send("ADV_BANNER_STATUS_CHANGE", array("ru", "en"), $arFields);
?>

See Also


© «Bitrix24», 2001-2024
Up