From 3ac5e4508b2c11f04acabbeb50bdbabcc904ec5e Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Sun, 7 Sep 2014 17:46:31 +0200 Subject: [PATCH] fix email to new registerd users. fix notification in case of error sending email. --- include/Emailer.php | 1 + include/enotify.php | 3 +-- include/user.php | 4 ++-- mod/register.php | 11 ++++++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/Emailer.php b/include/Emailer.php index 2baa279802..535a054289 100644 --- a/include/Emailer.php +++ b/include/Emailer.php @@ -57,6 +57,7 @@ class Emailer { ); logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG); logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG); + return $res; } } ?> diff --git a/include/enotify.php b/include/enotify.php index 9ca9d79703..bad94597aa 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -595,7 +595,7 @@ function notification($params) { // use the Emailer class to send the message - Emailer::send(array( + return Emailer::send(array( 'fromName' => $sender_name, 'fromEmail' => $sender_email, 'replyTo' => $sender_email, @@ -605,7 +605,6 @@ function notification($params) { 'textVersion' => $email_text_body, 'additionalMailHeader' => $datarray['headers'], )); - return True; } return False; diff --git a/include/user.php b/include/user.php index bf29daf1a6..eccfa7a08a 100644 --- a/include/user.php +++ b/include/user.php @@ -382,7 +382,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor The login details are as follows: Site Location: %3$s Login Name: %1$s - Password: %5$ + Password: %5$s You may change your password from your account "Settings" page after logging in. @@ -407,7 +407,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor $preamble = sprintf($preamble, $username, $sitename); $body = sprintf($body, $email, $sitename, $siteurl, $username, $password); - notification(array( + return notification(array( 'type' => "SYSTEM_EMAIL", 'to_email' => $email, 'subject'=> sprintf( t('Registration details for %s'), $sitename), diff --git a/mod/register.php b/mod/register.php index eb6fda737f..4ad84ecd6f 100644 --- a/mod/register.php +++ b/mod/register.php @@ -81,20 +81,25 @@ function register_post(&$a) { set_pconfig($user['uid'],'system','invites_remaining',$num_invites); } - send_register_open_eml( + $res = send_register_open_eml( $user['email'], $a->config['sitename'], $a->get_baseurl(), $user['username'], $result['password']); - if($res) { info( t('Registration successful. Please check your email for further instructions.') . EOL ) ; goaway(z_root()); } else { - notice( t('Failed to send email message. Here is the message that failed.') . $email_tpl . EOL ); + notice( + sprintf( + t('Failed to send email message. Here your accout details:
login: %s
password: %s

You can change your password after login.'), + $user['email'], + $result['password'] + ). EOL + ); } } elseif($a->config['register_policy'] == REGISTER_APPROVE) {