Skip to content

Instantly share code, notes, and snippets.

@demoriz
Last active June 5, 2019 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demoriz/d0094bfcf740b1d5fd5b1252469a9e45 to your computer and use it in GitHub Desktop.
Save demoriz/d0094bfcf740b1d5fd5b1252469a9e45 to your computer and use it in GitHub Desktop.
bitrix d7 'mail event'
<?php
use Bitrix\Main\Application;
use Bitrix\Main\Mail\Event;
$context = Application::getInstance()->getContext();
// if need file attach
$strUploadDir = $_SERVER['DOCUMENT_ROOT'] . '/upload/';
$strUploadFile = $strUploadDir . basename($arFile['name']);
$arMailFields = array(
'EVENT_NAME' => 'NEW_USER_NOTICE',
'LID' => $context->getSite(),
'C_FIELDS' => array(
'NAME' => $arClient['name'],
'EMAIL' => $arClient['email'],
'PASSWORD' => $strPasswd
),
'FILE' => array(
$strUploadFile // full path to file
)
);
$result = Event::send($arMailFields);
if (!$result->isSuccess()) {
print_r($result->getErrorMessages());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment