Setting up mail events and 1C-Bitrix templates

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Configuring Mail Events and Templates in 1C-Bitrix

After a site migration to a new server, orders stopped reaching the managers. The reason: the new server configuration had no valid SMTP settings, and mail events were configured with a non-existent sender address. Emails went out via sendmail, which silently dropped them; the Bitrix queue showed no errors. Customers submitted requests, managers saw nothing.

Mail events are critical site infrastructure, yet they receive minimal attention during initial setup.

Configuring Mail Events and Templates in 1C-Bitrix

Architecture of Mail Notifications in Bitrix

The Bitrix mail system consists of three layers:

Mail events (Settings → Mail → Mail Events) — event description: type (SALE_NEW_ORDER), list of macros available in templates. This is the event "interface".

Mail event templates (Settings → Mail → Mail Templates) — the concrete implementation: recipient, subject, email body. A single event type can have multiple templates for different sites or conditions.

Mail sending service — configured in Settings → Product Settings → Mail. Supported options: sendmail, mail(), SMTP (with authentication, SSL/TLS). For production, SMTP or an external service (Mailgun, SendGrid, Unisender, DashaMail) is mandatory.

Standard Events and Their Configuration

Bitrix ships with a set of pre-installed events. Key events for an online store:

  • SALE_NEW_ORDER — new order (sent to manager and customer)
  • SALE_ORDER_PAID — order paid
  • SALE_ORDER_CANCELED — order cancelled
  • SALE_STATUS_CHANGED — order status changed
  • MAIN_USER_REGISTER — user registration
  • MAIN_USER_PASS_CHANGED — password change

For each event, configure: sender address (FROM), recipient (TO), subject (SUBJECT), email body. Event macros are available in all fields.

A typical mistake: the FROM field contains an address on a domain different from the sending server's domain. SPF/DKIM fails, emails end up in spam.

SMTP Configuration

Section Settings → Product Settings → Mail → Mail Agent. Specify:

  • SMTP host (e.g., smtp.yandex.ru or a corporate server)
  • Port: 587 (STARTTLS) or 465 (SSL)
  • Mail account login and password
  • Encryption type

After configuration — always test via Settings → Diagnostics → Mail Test. If the email does not arrive, check /bitrix/modules/main/lib/mail/ and the SMTP server logs.

Creating Custom Mail Events

For custom notifications (e.g., "manager assigned to deal", "contract is about to expire"), create custom event types via the admin panel or programmatically using CEventType::Add(). Then create templates and trigger sending from code:

CEvent::Send('MY_CUSTOM_EVENT', SITE_ID, [
    'NAME' => $name,
    'EMAIL' => $email,
    'MESSAGE' => $text,
]);

Send Queue and Delays

By default, Bitrix sends emails through a queue — the CAgent::AddAgent() agent calls CMailMessage::SendMessages(). If agents are not running (no cron) or the queue has accumulated — emails are sent with a delay. For critical notifications (order, registration), enable immediate sending in the mail settings.

Timeline

Task Timeline
SMTP setup + verification of existing events 2–4 hours
Audit and configuration of all store events 4–8 hours
Creating custom events with templates 1–3 days