From: Raphaël Barrois Date: Wed, 27 May 2009 13:57:58 +0000 (+0200) Subject: Adds support for "catchmail" config value X-Git-Tag: core/1.0.1~15 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=0d40ddec57550773766a877a250d60dd8dd3052a;p=platal.git Adds support for "catchmail" config value Set in [Core] section, forces all mails to be sent to admin_email instead of the recipients defined by addTo, addCc, addBcc. Useful for development purposes. Signed-off-by: Raphaël Barrois --- diff --git a/classes/plglobals.php b/classes/plglobals.php index 9818db1..0fe88f1 100644 --- a/classes/plglobals.php +++ b/classes/plglobals.php @@ -64,6 +64,13 @@ class PlGlobals // 'r' => read/only // '' => site down + /** Catch-all mode for mails + * If set to 1, all emails are sent to admin_email (defined in [Core]) + * instead of their actual destination (but apparent from and to aren't + * modified) + */ + public $catchmail = false; + /** Tell smarty to check the timestamps of the templates to decide * whether recompile the template or not. If this option is false and * debug mode is not activate, templates won't be recompile if they changed. diff --git a/classes/plmailer.php b/classes/plmailer.php index 2106f02..e3e348d 100644 --- a/classes/plmailer.php +++ b/classes/plmailer.php @@ -347,6 +347,18 @@ class PlMailer extends Mail_Mime { $dests[] = "{$a->mailbox}@{$a->host}"; } + // Support for "catch-all" mail address : all emails are sent to + // admin_email instead of actual recipients + global $globals; + if($globals->catchmail) { + require_once 'Mail/RFC822.php'; + if(@Mail_RFC822::isValidInetAddress($globals->admin_email)){ + $dests = array($globals->admin_email); + }else if(@Mail_RFC822::isValidInetAddress($globals->core->admin_email)){ + $dests = array($globals->core->admin_email); + } + } + // very important to do it in THIS order very precisely. $body = $this->get(array('text_charset' => $this->charset, 'text_encoding' => '8bit',