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!