Commit 02a0b90e authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Merge branch 'master' of git+ssh://git.mahara.org/git/mahara

Conflicts:

	htdocs/lib/user.php
parents b3011ee6 b690cde0
......@@ -116,6 +116,17 @@ $cfg->log_backtrace_levels = LOG_LEVEL_WARN | LOG_LEVEL_ENVIRON;
// developing for Mahara
$cfg->developermode = false;
// Whether to send e-mail. If set to false, Mahara will not send any e-mail at
// all. This is useful for when setting up development versions of Mahara where
// you don't want to accidentally send email to users from this particular
// Mahara installation.
//
// You can use sendallemailto to have all e-mails from this instance of Mahara
// sent to one particular address instead of where they're aimed for. Leave
// sendemail = true if you want to use this setting.
$cfg->sendemail = true;
// $cfg->sendallemailto = 'you@example.com';
// capture performance information and print it
// $cfg->perftofoot = true; // needs a call to mahara_performance_info (smarty callback) - see default theme's footer.tpl
// $cfg->perftolog = true;
......
......@@ -359,6 +359,7 @@ $string['noinstitutionsetpassemailmessagehtml'] = '<p>Dear %s,</p>
<p>Regards, %s Site Administrator</p>
<p><a href="' . get_config('wwwroot') . 'forgotpass.php?key=%s">' . get_config('wwwroot') . 'forgotpass.php?key=%s</a></p>';
$string['debugemail'] = 'NOTICE: This e-mail was intended for %s <%s> but has been sent to you as per the "sendallemailto" configuration setting.';
// Expiry times
......
......@@ -271,6 +271,11 @@ function get_profile_field($userid, $field) {
* @throws EmailException
*/
function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml='', $customheaders=null) {
if (!get_config('sendemail')) {
// You can entirely disable Mahara from sending any e-mail via the
// 'sendemail' configuration variable
return true;
}
if (empty($userto)) {
throw new InvalidArgumentException("empty user given to email_user");
......@@ -327,8 +332,20 @@ function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml='',
$mail->Subject = substr(stripslashes($subject), 0, 900);
$usertoname = display_name($userto, $userto);
$mail->AddAddress($userto->email, $usertoname );
if ($to = get_config('sendallemailto')) {
// Admins can configure the system to send all email to a given address
// instead of whoever would receive it, useful for debugging.
$mail->addAddress($to);
$notice = get_string('debugemail', 'mahara', display_name($userto, $userto), $userto->email);
$messagetext = $notice . "\n\n" . $messagetext;
if ($messagehtml) {
$messagehtml = '<p>' . $notice . '</p>' . $messagehtml;
}
}
else {
$usertoname = display_name($userto, $userto);
$mail->AddAddress($userto->email, $usertoname );
}
$mail->WordWrap = 79;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment