R
R
Roman2014-10-08 19:43:02
PHP
Roman, 2014-10-08 19:43:02

How to send mail by event in Bitrix?

Good day!
In stock Bitrix (Corporate portal 14.9.3.).
In the user's notification settings, the "send by email" checkboxes are checked everywhere ( cl.ly / Xx56)
When new comments or likes are made on the site, notifications appear, but the mail does not come. Sending other emails (for example, password recovery) works.
How to add an event handler that would send this notification to the mail? The update doesn't break anything.
I tried to do something like this in init.php:

AddEventHandler('im', "OnAddRatingVote", "OnAfterImHandler");
function OnAfterImHandler($arFields) {
    die('Sup');
}

But alas, the code inside the callback is not executed. I found a post on the forum without a single answer from 12 years and nothing more.
Further, inside bitrix/modules/im/classes/general/im_mail.php there is a MailMessageAgent() method, inside of which there is a line:
$arUnsendMessage = CIMMessage::GetUnsendMessage();
But it always returns an empty number of messages, because by the time of this request a new notification has already been sent and the success flag is set.
I have no idea where to dig further):

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Savrasov, 2014-10-09
@alcorn

You are using the wrong class. im this is a messenger class, and you need to catch the comment adding event.
Comments in the corporal are implemented on the basis of blogs like.
Therefore, a handler must be added to init.php.

AddEventHandler('blog', "OnBeforeCommentAdd", "OnAfterImHandler");
function OnAfterImHandler($arFields) {
    die('Sup');
}

You here: dev.1c-bitrix.ru/api_help/blogs/events/index.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question