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_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,'[email protected]');
$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');
$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;
Instead of the code above I had to use this one:
<?php
$headers .= "From: COMPANY<[email protected]>\n";
$headers .= "BCC: <[email protected]>\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
<p>';
$to = "[email protected]";
$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:
[[+reg.error.message]]
[[+reg.error]]
[[+reg.errors]]
[[!+reg.error.message]]
[[!+reg.error]]
[[!+reg.errors]]
But no output on this at all.
Using the other placeholders like
[[!+reg.error.fullname]]
[[!+reg.error.username]]
[[!+reg.error.password]]
[[!+reg.error.password_confirm]]
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.