E-mail system is technology designed for handling e-mail messages on site.
Working with the mail system consists of the following stages:
- 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.
- Creating an email template. Available in the admin section "Email Templates" menu, as well as via the function CEventMessage::Add.
- 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:
- select from the table b_event the unprocessed email events
- generate email messages (email) for them
- send them
- 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:
- Convert the new Unix string characters into the Windows format when sending an email
- Converts 8-byte characters in the email header
- E-mail address or list of comma-separated addresses to duplicate all outgoing messages
- Duplicate e-mail address to the title
- Send email event and template IDs in the email
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"] = "email@example.com"; $arr["EMAIL_TO"] = "firstname.lastname@example.org"; $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); ?>