diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-03-09 12:44:28 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-03-09 12:44:28 +0100 |
commit | 9f3eca0b520fc5f689170108fbcbf490d12f2c2e (patch) | |
tree | 136343e3f3fe1b2bee92a126639c68aa087780b1 | |
parent | d2113a3cac4f670858d94dc53de4f653828dac91 (diff) | |
download | rpg-9f3eca0b520fc5f689170108fbcbf490d12f2c2e.tar.gz rpg-9f3eca0b520fc5f689170108fbcbf490d12f2c2e.tar.bz2 |
Add various headers to the mails FS#2247. pull request #83 closed
-rw-r--r-- | inc/Mailer.class.php | 23 | ||||
-rw-r--r-- | inc/common.php | 7 | ||||
-rw-r--r-- | inc/subscription.php | 6 |
3 files changed, 28 insertions, 8 deletions
diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index 753ea3fd6..141b69a18 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -33,14 +33,23 @@ class Mailer { * Initializes the boundary strings and part counters */ public function __construct(){ - if(isset($_SERVER['SERVER_NAME'])){ - $server = $_SERVER['SERVER_NAME']; - }else{ - $server = 'localhost'; - } + global $conf; + + $server = parse_url(DOKU_URL,PHP_URL_HOST); $this->partid = md5(uniqid(rand(),true)).'@'.$server; $this->boundary = '----------'.md5(uniqid(rand(),true)); + + $listid = join('.',array_reverse(explode('/',DOKU_BASE))).$server; + $listid = strtolower(trim($listid,'.')); + + // add some default headers for mailfiltering FS#2247 + $this->setHeader('X-Mailer','DokuWiki '.getVersion()); + $this->setHeader('X-DokuWiki-User', $_SERVER['REMOTE_USER']); + $this->setHeader('X-DokuWiki-Title', $conf['title']); + $this->setHeader('X-DokuWiki-Server', $server); + $this->setHeader('X-Auto-Response-Suppress', 'OOF'); + $this->setHeader('List-Id',$conf['title'].' <'.$listid.'>'); } /** @@ -114,10 +123,10 @@ class Mailer { * @param bool $clean remove all non-ASCII chars and line feeds? */ public function setHeader($header,$value,$clean=true){ - $header = ucwords(strtolower($header)); // streamline casing + $header = str_replace(' ','-',ucwords(strtolower(str_replace('-',' ',$header)))); // streamline casing if($clean){ $header = preg_replace('/[^\w \-\.\+\@]+/','',$header); - $value = preg_replace('/[^\w \-\.\+\@]+/','',$value); + $value = preg_replace('/[^\w \-\.\+\@<>]+/','',$value); } // empty value deletes diff --git a/inc/common.php b/inc/common.php index 5e2bb7c93..79646eadc 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1152,6 +1152,13 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){ $mail->bcc($bcc); $mail->subject($subject); $mail->setBody($text,$trep,$hrep); + if($who == 'subscribers'){ + $mail->setHeader( + 'List-Unsubscribe', + '<'.wl($id,array('do'=>'subscribe'),true,'&').'>', + false + ); + } return $mail->send(); } diff --git a/inc/subscription.php b/inc/subscription.php index e9f17bc28..d1ee0397a 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -387,6 +387,10 @@ function subscription_send($subscriber_mail, $replaces, $subject, $id, $template $mail->bcc($subscriber_mail); $mail->subject($subject); $mail->setBody($text,$trep); - + $mail->setHeader( + 'List-Unsubscribe', + '<'.wl($id,array('do'=>'subscribe'),true,'&').'>', + false + ); return $mail->send(); } |