<?
if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) die();

use Bitrix\Main\Mail\Event;
use Bitrix\Main\Application;

//echo '<pre>';
//print_r($arParams);
//echo '</pre>';

$request = Application::getInstance()->getContext()->getRequest();
$postData = $request->getPostList()->toArray();

if (
    $request->isPost() &&
    check_bitrix_sessid() &&
    $postData['FROM_EMAIL'] &&
    $postData['TEXT']
) {

    Event::send(array(
        "EVENT_NAME" => "ABOUT_YOU_BULLETIN",
        "LID" => "s2",
        "C_FIELDS" => array(
            'BULLETIN_NAME' => $arParams['BULLETIN_NAME'],
            'BULLETIN_URL' => $arParams['BULLETIN_URL'],
            "TO_EMAIL" => $arParams['BULLETIN_OWNER_MAIL'],
            "FROM_EMAIL" => $postData['FROM_EMAIL'],
            "TEXT" => $postData['TEXT'],
        ),
    ));

    $arResult['OK_MESSAGE'] = 'Успешно отправлено';
}

$this->includeComponentTemplate();
