On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hm...i got the admin-email sending by not using the "normal"-way:

    $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_FROM_NAME,'My Site');
    $modx->mail->set(modMail::MAIL_SENDER,'My Site');
    $modx->mail->set(modMail::MAIL_SUBJECT,'New User Signed Up');
    if (!$modx->mail->send()) {
        $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
    /* tell our snippet we're good and can continue */
    return true;

    Instead of the code above I had to use this one:

    $headers .= "From: COMPANY<info@abc.de>\n"; 
    $headers .= "BCC: <kontakt@abc.com>\n";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; //
    $message = 'Hallo!
    <p>Ein neuer Benutzer hat sich angemeldet.</p>
    Benutzername: <strong>'.$hook->getValue('username')
     . '</strong><br />
    Email-Adresse: <strong>'.$hook->getValue('email').'</strong></p>
    Mit freundlichen Grüßen
    $to = "info@abc.de";
    $subject = "Neue Anmeldung";
     if (mail($to, $subject, $message, $headers)) {
       echo("<p>Message successfully sent!</p>");
      } else {
       echo("<p>Message delivery failed...</p>");

    So this is working now for me!

    But I still have troubles getting the general error-message displayed; I tried different variations for the placeholder:


    But no output on this at all.

    Using the other placeholders like


    does work.

    So what can be the problem the general error-message doesn't get displayed?

    Furthermore my customer wants a "Forgot Username"-functionality; does anyone has done something like that before? I tried to do it on my own by copying the ForgotPassword-snippet and to dublicate the file at /core/components/login/controllers/web/ForgotPassword.php to ForgotUsername.php and edit this one, but without any luck so far.
    • thank you profilneurotiker for the code you shared ; i encounter exactly the same problems : the admin-email won't be sent if I use the code that is given in the official documentation (the "normal" way, like you said). Your code solved this. Again, thank you. [ed. note: kehezen last edited this post 5 years, 6 months ago.]
        Sorry for that ⇧ , I'm no dev but I wanna try
      • Hello kehezen!

        No problem!

        And, I did manage the general-error-message problem with a hard-coded workaround, see this thread:


        EDIT: Oh...I just saw the question about the general-error-message isn't inside your post anymore, but I read about this in the notify-email from the MODx-Forum. I guess you found my other thread or solved this in another way.
        • I have the same problem. I follow this guide:
          i regive this error:
          [2015-07-05 14:18:04] (ERROR @ /index.php) Could not get table class for class: modAccess
          [2015-07-05 14:18:04] (ERROR @ /index.php) Could not get table name for class: modAccess
          [2015-07-05 14:18:04] (ERROR @ /index.php) Error 42000 executing statement: 
              [0] => 42000
              [1] => 1064
              [2] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS `modAccess` WHERE `modAccess`.`principal` = 55' at line 1
          [2015-07-05 14:18:05] (ERROR @ /index.php) An error occurred while trying to send the email:

          In my registration, the user not confirm the registration but for confirm i use the ActivationEmail plugin. But i want advise the admin when the user do registration.
          • What about the built in "email" hook?

            And for the error message placeholder: try
            without the prefix... (e.g. no "reg." in front), does that help?