Documentation

BeforePostingSendMail

Description and parameters

handler function(
 array arFields
);
The event "BeforePostingSendMail" is called before sending a message from method CPosting::SendMessage.

Parameters

ParameterDescription
arFields Array containing the following:
  • POSTING_ID - message ID.
  • EMAIL - address to send the message на который будет отправлен выпуск.
  • SUBJECT - email header (in encoded format, if corresponding module setting is enabled).
  • BODY - email body, already formatted according to the MIME standard.
  • HEADER - service headers.
  • EMAIL_EX - extra information about recipient, see CPosting fields.

This handler must return an array with similar contents. This array will be passed as an argument to the next handler. Handler result integrity check is not performed in the module.

If the handler doesn't return an array, no email is sent. However, in case of false return, the email is deemed unsent, otherwise the sending will be marked as successful.

See Also

Example of handler function

<?
// file /bitrix/php_interface/init.php
// register the handler
AddEventHandler("subscribe", "BeforePostingSendMail", Array("MyClass", "BeforePostingSendMailHandler"));
class MyClass { // create event handler "BeforePostingSendMail" public static function BeforePostingSendMailHandler($arFields) { $USER_NAME = "Subscriber"; //Attempt to find a subscriber. $rs = CSubscription::GetByEmail($arFields["EMAIL"]); if($ar = $rs->Fetch()) { if(intval($ar["USER_ID"]) > 0) { $rsUser = CUser::GetByID($ar["USER_ID"]); if($arUser = $rsUser->Fetch()) { $USER_NAME = $arUser["NAME"]." ".$arUser["LAST_NAME"]; } } } $arFields["BODY"] = str_replace("#NAME#", $USER_NAME, $arFields["BODY"]);
return $arFields;
}
}
?>

© «Bitrix24», 2001-2024
Up