We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40122
    • 330 Posts
    I am trying to use Post Hooks to send an email to my site's administrator when a user signs up using the Login plugin's Register component.

    I followed the example here: http://rtfm.modx.com/extras/revo/login/login.tutorials/login.using-pre-and-post-hooks

    And everything seems to work fine but I do not receive any emails from the Hook Snippet.

    My Register Snippet call looks like:

    [[!Register?
        &submitVar=`registerbtn`
        &activationResourceId=`19`
        &activationEmailTpl=`lgnActivateEmailTpl`
        &activationEmailSubject=`Thanks for Registering!`
        &submittedResourceId=`23`
        &usergroups=`2`
        &postHooks=`adminEmailHook`
        &validate=`nospam:blank,
        username:required:minLength=^6^,
        password:required:minLength=^6^,
        password_confirm:password_confirm=^password^,
        fullname:required,
        email:required:email`
    ]]


    and my Hook Snippet, "adminEmailHook" looks like:

    <?php
    $message = 'Hi, a new User signed up: '.$hook->getValue('username')
     . ' with email '.$hook->getValue('email').'. To activate this User please login to the ModX Manager and navigate to the Users menu under the Manage drop down menu.';
    $modx->getService('mail', 'mail.modPHPMailer');
    $modx->mail->set(modMail::MAIL_BODY,$message);
    $modx->mail->set(modMail::MAIL_FROM,'[email protected]');
    $modx->mail->set(modMail::MAIL_FROM_NAME,'Company');
    $modx->mail->set(modMail::MAIL_SENDER,'Company');
    $modx->mail->set(modMail::MAIL_SUBJECT,'New User Signed Up');
    $modx->mail->address('to','[email protected]');
    $modx->mail->setHTML(true);
    if (!$modx->mail->send()) {
        $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the new user alert email: '.$err);
    }
    $modx->mail->reset();
    /* tell our snippet we're good and can continue */
    return true;


    - almost verbatim from the example.

    Would anyone know why I am not able to receive the email? Are they sent differently?

    Nothing appears in the error logs. I am using Revo 2.3.3

    Any advice is appreciated!

    This question has been answered by istvan.velsz. See the first response.

    [ed. note: meltingdog last edited this post 9 years ago.]
      • 50145
      • 5 Posts
      best.peterburg Reply #2, 9 years ago
      if your site is online try to change this e-mail
      $modx->mail->set(modMail::MAIL_FROM,'[email protected]');

      You need a real e-mail from domain of your site
        • 40122
        • 330 Posts
        Quote from: best.peterburg at Mar 25, 2015, 12:03 PM
        if your site is online try to change this e-mail
        $modx->mail->set(modMail::MAIL_FROM,'[email protected]');

        You need a real e-mail from domain of your site

        Thanks but no luck there - made no difference
          • 34103
          • 47 Posts
          Same problem. If I use SMTP System settings it doesn't work, but without SMPT it works. How to change snippet to wort with system SMTP settings?
          • discuss.answer
            • 34103
            • 47 Posts
            [solved] The sender
            $modx->mail->set(modMail::MAIL_SENDER,'[email protected]');
            has to be a vaild email address like FROM.