;

Плагин для отправки электронной почты при публикации ресурса

MODX Revolution

20-01-2017

Удобно использовать, например, для автоматического оповещения автора документа о публикации статьи
$eventName = $modx->event->name;
switch($eventName) {
    case 'OnDocPublished':

$res = $modx->getObject('modResource', $id);
$author = $res->get('createdby');
$link = $modx->makeUrl($id, '', 'a=1','https');

$user = $modx->getObject('modUser',array('active' => true, 'id' => $author ));

$profile = $user->getOne('Profile');
$useremail = $profile->get('email');
$usernamec = $profile->get('fullname');
$username = ', '.$profile->get('fullname');

$subject ='Your ad has been added';
$message = '

Hi'.$username.'!

Your ad has successfully passed moderation!
'; // To send an HTML email, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; // Additional headers $headers .= 'To: '.$usernamec.' <'.$useremail.'>' . "\r\n"; $headers .= 'From: Admin ' . "\r\n"; // send mail($to, $subject, $message, $headers); break; }