From 0d40ddec57550773766a877a250d60dd8dd3052a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Wed, 27 May 2009 15:57:58 +0200 Subject: [PATCH] Adds support for "catchmail" config value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- classes/plglobals.php | 7 +++++++ classes/plmailer.php | 12 ++++++++++++ 2 files changed, 19 insertions(+) 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', -- 2.1.4