MDL-18903 All outgoing emails can be diverted into a single address

This is highly useful when developing or debugging any emailing feature.
Backported from 2.0dev
This commit is contained in:
David Mudrak
2010-04-02 09:33:11 +00:00
parent e8ee0a0720
commit 503b8b480a
2 changed files with 8 additions and 0 deletions
+2
View File
@@ -364,6 +364,8 @@ $CFG->admin = 'admin';
// When working with production data on test servers, no emails should ever be send to real users
// $CFG->noemailever = true;
//
// Divert all outgoing emails to this address to test and debug emailing features
// $CFG->divertallemailsto = '[email protected]';
//
//=========================================================================
// ALL DONE! To continue installation, visit your main page with a browser
+6
View File
@@ -4207,6 +4207,12 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $a
return true;
}
if (!empty($CFG->divertallemailsto)) {
$subject = "[DIVERTED {$user->email}] $subject";
$user = clone($user);
$user->email = $CFG->divertallemailsto;
}
// skip mail to suspended users
if (isset($user->auth) && $user->auth=='nologin') {
return true;