Отправка на почту в плагине

почему не отправляется почта в плагине при регистрации?
<?php
if ($modx->context->key != 'mgr') {
    switch ($modx->event->name) {
        // Событие перед регистрацией пользователя
        case 'OnBeforeUserFormSave':
            if ($mode != 'new') {
                return;
            }
            if (empty($_POST['email'])) {
                 $modx->event->output('Укажите электронную почту');
            }
 
            break;
         case 'OnUserFormSave':
            if ($mode == 'new') {
                $message = $modx->getChunk('myEmailTemplate',array('name' => $_POST['email']));
                //$modx->event->output($message);
                $modx->getService('mail', 'mail.modPHPMailer');
                $modx->mail->set(modMail::MAIL_BODY,$message);
                $modx->mail->set(modMail::MAIL_FROM,'maksim@outlook.com');
                $modx->mail->set(modMail::MAIL_FROM_NAME,'site.im');
                $modx->mail->set(modMail::MAIL_SUBJECT,'ваши данные site.im');
                $modx->mail->address('to', $_POST['email']);
                $modx->mail->address('reply-to','maksim@outlook.com');
                $modx->mail->setHTML(true);
                if (!$modx->mail->send()) {
                    $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$modx->mail->mailer->ErrorInfo);
                }else{
                    $modx->log(modX::LOG_LEVEL_ERROR,$message);
                }
                $modx->mail->reset(); 
                $user->Profile->set('active', 1);
            }
            break;
    }
}
Aslero
18 июня 2019, 13:45
modx.pro
625
0

Комментарии: 8

Андрей
18 июня 2019, 13:50
+1
События по идее должны быть другие — OnUserBeforeSave и OnUserSave.
    Aslero
    18 июня 2019, 13:56
    0
    все ровно не отправляет
    Aslero
    18 июня 2019, 13:57
    0
    консоль чистая
    Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
    8