Commit ccc8e39d authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Optional logging of outgoing email


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent d17804fe
......@@ -131,6 +131,9 @@ $cfg->developermode = false;
// sendemail = true if you want to use this setting.
$cfg->sendemail = true;
// $cfg->sendallemailto = 'you@example.com';
//
// Log basic details of emails sent out by Mahara. This will get big.
// $cfg->emaillog = $cfg->dataroot . '/log/email.log';
// capture performance information and print it
// $cfg->perftofoot = true; // needs a call to mahara_performance_info (smarty callback) - see default theme's footer.tpl
......
......@@ -400,6 +400,7 @@ function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml='',
throw new EmailException("Cannot send email to $usertoname with subject $subject. User has no primary email address set.");
}
$mail->AddAddress($userto->email, $usertoname );
$to = $userto->email;
}
$mail->WordWrap = 79;
......@@ -416,6 +417,17 @@ function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml='',
}
if ($mail->Send()) {
if ($logfile = get_config('emaillog')) {
$docroot = get_config('docroot');
@$client = (string) $_SERVER['REMOTE_ADDR'];
@$script = (string) $_SERVER['SCRIPT_FILENAME'];
if (strpos($script, $docroot) === 0) {
$script = substr($script, strlen($docroot));
}
$line = "$to <- $mail->From - " . str_shorten_text($mail->Subject, 50);
@error_log('[' . date("Y-m-d h:i:s") . "] [$client] [$script] $line\n", 3, $logfile);
}
// Update the count of sent mail
update_send_count($userto);
......
Supports Markdown
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