openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 56ffee2f31c3829f089ea28cba3abf9900cdca64
parent 951ea0518e0fc76f46d62e16073c07b64e6fd8e9
Author: dankert <devnull@localhost>
Date:   Fri, 25 Sep 2009 00:43:37 +0200

White- und Blacklisting für E-Mail-Domains

Diffstat:
config/mail.ini.php | 13+++++++++++--
serviceClasses/Mail.class.php | 32++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/config/mail.ini.php b/config/mail.ini.php @@ -41,6 +41,15 @@ header_encoding="Quoted-printable" ;client=smtp client=php + +; Whitelist +; A comma-seperated list of domains names +whitelist = "" + +; Blacklist +; A comma-seperated list of domain names +blacklist = "" + ; Settings for the internal SMTP client. @@ -53,7 +62,7 @@ client=php ; If this is blank, the mail is delivered directly to the destination MX host. ; I repeat, it is better to always use a relay host! ;host="mail.yourdomain.example" -host="locahost" +host="locahost" ; SMTP-Port is '25' in most environments port="25" @@ -80,4 +89,4 @@ tls=false ; Use SSL ; The client will connection using the SSL-protocol. ; This is not tested, use at your own risk! -ssl=false +ssl=false diff --git a/serviceClasses/Mail.class.php b/serviceClasses/Mail.class.php @@ -152,6 +152,38 @@ class Mail { global $conf; + $to_domain = array_pop( explode('@',$this->to) ); + + // Prüfen gegen die Whitelist + $white = explode(',',@$conf['mail']['whitelist']); + if ( count($white) > 0 ) + { + $ok = false; + foreach( $white as $domain ) + if ($domain == substr($to_domain,-strlen($domain))) + { + $ok = true; + break; + } + + if ( !$ok) + { + // Wenn Domain nicht in Whitelist gefunden, dann Mail nicht verschicken. + $this->error[] = 'Mail-Domain is not whitelisted'; + return false; + } + } + + // Prüfen gegen die Blacklist + $black = explode(',',@$conf['mail']['blacklist']); + foreach( $black as $domain ) + if ($domain == substr($to_domain,0,strlen($domain))) + { + // Wenn Domain in Blacklist gefunden, dann Mail nicht verschicken. + $this->error[] = 'Mail-Domain is blacklisted'; + return false; + } + // Header um Adressangaben erg�nzen. if ( !empty($this->from ) ) $this->header[] = 'From: '.$this->from;