Using Rev 2.2.4-pl and latest Login package.
I am trying to get Register to send me an email when a new User registers on a site following the instructions at:
http://rtfm.modx.com/display/ADDON/Login.Using+Pre+and+Post+Hooks
I am unable to get the following to send an email:
<?php
$message = 'Hi, a new User signed up: ';
$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,'ME');
$modx->mail->set(modMail::MAIL_SENDER,'me');
$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;
?>
However this code will send an email successfully:
<?php
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
?>
}
So I know that the system is able to send emails successfully?
What am I missing?