We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12352
    • 101 Posts
    Hi, I’m trying to get the e-mail to work when a user registers on the site in the examples section of this documentation:
    http://rtfm.modx.com/display/ADDON/Login.Using+Pre+and+Post+Hooks

    Confirm e-mails to the user work fine, but the e-mail to the administrator doesn’t work.

    Here’s the postHook: bcHookAdminEmail

    <?php
    $message = 'Hi, a new User signed up: '.$hook->getValue('username')
     . ' with email '.$hook->getValue('email').'.';
     
    $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,'MyDomain');
    $modx->mail->set(modMail::MAIL_SENDER,'MyDomain');
    $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 email: '.$err);
    }
    $modx->mail->reset();
    /* tell our snippet we're good and can continue */
    return true;


    Register snippet call:
    [[!Register? &submitVar=`registerbtn` &activationResourceId=`978` &activationEmailTpl=`bcActivationEmailTpl` &activationEmailSubject=`Thanks for Registering!` &submittedResourceId=`976` &usergroups=`BadCamberg` &postHooks=`bcHookAdminEmail` ]]


    thanks in advance!
      Don't believe anything you read on the net. Except this.
      • 12352
      • 101 Posts
      Any ideas, please? Still doesn’t work...
        Don't believe anything you read on the net. Except this.
        • 34108
        • 66 Posts
        I’m having the exact same problem, did you find a solution Hori? Or does anyone else have any ideas?

        I’m using the code exact as it’s explained here - http://rtfm.modx.com/display/ADDON/Login.Using+Pre+and+Post+Hooks

        Only thing I could think of - where the snippet calls for "$modx->getService(’mail’, ’mail.modPHPMailer’)" is that a particular package that needs to be installed or a system setting that needs to be changed?

        Alternatively, is there any way to simply BCC an email address so when the user registers they get the standard email and the administrator also gets a copy of the email?

        Thanks
        Harmony
          • 12352
          • 101 Posts
          No, still no solution, I’m using the same code

          there must be something wrong with the postHook, because the activation e-mail works fine.
            Don't believe anything you read on the net. Except this.
            • 17016
            • 138 Posts
            Quote from: harmonysteel at Feb 25, 2011, 12:37 AM

            Only thing I could think of - where the snippet calls for "$modx->getService(’mail’, ’mail.modPHPMailer’)" is that a particular package that needs to be installed or a system setting that needs to be changed?
            Same problem here. "modPHPMailer" doesn´t work on our system. Are there any important settings which we have to change? For example "Use SMTP"=yes?
              • 3749
              • 24,544 Posts
              I don’t know why the postHook isn’t working, it certainly looks like it should. This might be a workaround:

              In the core/components/login/model/login/login.class.php file:

              Change this:
               
              $this->modx->mail->address('to', $email, $name);

              to this:
              $this->modx->mail->address('to', $email, $name);
              $this->modx->mail->address('bcc', '[email protected]');


              That should send the admin the same email the user gets.

              Of course that code might be overwritten when the package is updated.

                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
              • Hi there, this snippet does work in so far as it fires an email to notify that a new user has registered, however, it does not fill in the username, fullname and email for the message.

                I have logged a bug http://bugs.modx.com/issues/5823 and hopefully this will be resolved soon.

                For info it worked with Login 1.6.5 on Revo 2.1.3 but doesn't work with Login 1.7.0 rc2.
                  Helen Warner
                  Number one pixel!
                  Proud to be linked with MODX at Crimson Pixel
                • This bug has now been fixed thank you to Splittingred for all the work.

                  Download latest version and ensure you're using Revo 2.1.x +.
                    Helen Warner
                    Number one pixel!
                    Proud to be linked with MODX at Crimson Pixel
                    • 36613
                    • 328 Posts
                    Anyone Resolved ? In my modx doen't work.