Permalink
Browse files

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
  • Loading branch information...
mudrd8mz committed Apr 2, 2010
1 parent e8ee0a0 commit 503b8b480a39ef4817dd2abf77dba0ff476ddce5
Showing with 8 additions and 0 deletions.
  1. +2 −0 config-dist.php
  2. +6 −0 lib/moodlelib.php
View
@@ -364,6 +364,8 @@
// 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 = 'root@localhost.local';
//
//=========================================================================
// ALL DONE! To continue installation, visit your main page with a browser
View
@@ -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;

0 comments on commit 503b8b4

Please sign in to comment.