Merge branch 'MDL-48080_master' of https://github.com/crazyserver/moodle

This commit is contained in:
Andrew Nicols 2015-01-07 10:52:04 +08:00
commit 0d3e8ed4f6

View File

@ -5800,23 +5800,22 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '',
if (!validate_email($user->email)) {
// We can not send emails to invalid addresses - it might create security issue or confuse the mailer.
$invalidemail = "User $user->id (".fullname($user).") email ($user->email) is invalid! Not sending.";
error_log($invalidemail);
if (CLI_SCRIPT) {
mtrace('Error: lib/moodlelib.php email_to_user(): '.$invalidemail);
}
debugging("email_to_user: User $user->id (".fullname($user).") email ($user->email) is invalid! Not sending.");
return false;
}
if (over_bounce_threshold($user)) {
$bouncemsg = "User $user->id (".fullname($user).") is over bounce threshold! Not sending.";
error_log($bouncemsg);
if (CLI_SCRIPT) {
mtrace('Error: lib/moodlelib.php email_to_user(): '.$bouncemsg);
}
debugging("email_to_user: User $user->id (".fullname($user).") is over bounce threshold! Not sending.");
return false;
}
// TLD .invalid is specifically reserved for invalid domain names.
// For More information, see {@link http://tools.ietf.org/html/rfc2606#section-2}.
if (substr($user->email, -8) == '.invalid') {
debugging("email_to_user: User $user->id (".fullname($user).") email domain ($user->email) is invalid! Not sending.");
return true; // This is not an error.
}
// If the user is a remote mnet user, parse the email text for URL to the
// wwwroot and modify the url to direct the user's browser to login at their
// home site (identity provider - idp) before hitting the link itself.