1586

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

<?php
// Created by Morn Gail https://morngail.com

$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 = '<h3>Hi'.$username.'!</h3>
Your ad has successfully passed moderation!<br />
';
 // 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 <admin@domain.ru>' . "\r\n";

// send
mail($to, $subject, $message, $headers);

break;

}
Comment