diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-10-12 13:30:54 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-10-12 13:30:54 +0200 |
commit | d6e04b603a81d6c55c3bb71974689892762b6a01 (patch) | |
tree | b093a57b0cd2ad05153eddeb314beab156e3d7a5 | |
parent | 0ee5ed1e998c1e67c4a0b7687977c4e2e0f29494 (diff) | |
download | rpg-d6e04b603a81d6c55c3bb71974689892762b6a01.tar.gz rpg-d6e04b603a81d6c55c3bb71974689892762b6a01.tar.bz2 |
successfully validate Mailer mails with msglint
-rw-r--r-- | _test/tests/inc/mailer.test.php | 7 | ||||
-rw-r--r-- | inc/Mailer.class.php | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/_test/tests/inc/mailer.test.php b/_test/tests/inc/mailer.test.php index fefb6f508..feb454fcf 100644 --- a/_test/tests/inc/mailer.test.php +++ b/_test/tests/inc/mailer.test.php @@ -164,6 +164,7 @@ class mailer_test extends DokuWikiTest { // prepare a simple multipart message $mail = new TestMailer(); $mail->to(array('Möp <moep@example.com> ',' foo <foo@example.com>')); + $mail->from('Me <test@example.com>'); $mail->subject('This is a töst'); $mail->setBody('Hello Wörld, @@ -173,6 +174,8 @@ class mailer_test extends DokuWikiTest { $msg = $mail->dump(); $msglines = explode("\n", $msg); + //echo $msg; + // ask message lint if it is okay $html = new HTTPClient(); $results = $html->post('http://tools.ietf.org/tools/msglint/msglint', array('msg'=>$msg)); @@ -195,6 +198,10 @@ class mailer_test extends DokuWikiTest { // check the line for errors if(substr($line,0,5) == 'ERROR'){ + // ignore some errors + if(strpos($line, "missing mandatory header 'return-path'")) continue; #set by MDA + if(strpos($line, "bare newline in text body decoded")) continue; #seems to be false positive + // get the context in which the error occured $errorin = ''; if(preg_match('/line (\d+)$/', $line, $m)){ diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index 0f3321bb9..ff29c2a36 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -41,6 +41,7 @@ class Mailer { global $conf; $server = parse_url(DOKU_URL, PHP_URL_HOST); + if(strpos($server,'.') === false) $server = $server.'.localhost'; $this->partid = md5(uniqid(rand(), true)).'@'.$server; $this->boundary = '----------'.md5(uniqid(rand(), true)); @@ -57,6 +58,7 @@ class Mailer { $this->setHeader('X-DokuWiki-Server', $server); $this->setHeader('X-Auto-Response-Suppress', 'OOF'); $this->setHeader('List-Id', $conf['title'].' <'.$listid.'>'); + $this->setHeader('Date', date('r'), false); } /** @@ -426,7 +428,8 @@ class Mailer { } $mime .= '--'.$this->boundary.MAILHEADER_EOL; - $mime .= 'Content-Type: '.$media['mime'].';'.MAILHEADER_EOL; + $mime .= 'Content-Type: '.$media['mime'].';'.MAILHEADER_EOL. + ' id="'.$cid.'"'.MAILHEADER_EOL; $mime .= 'Content-Transfer-Encoding: base64'.MAILHEADER_EOL; $mime .= "Content-ID: <$cid>".MAILHEADER_EOL; if($media['embed']) { @@ -487,7 +490,8 @@ class Mailer { $body .= chunk_split(base64_encode($this->text), 74, MAILHEADER_EOL); $body .= '--'.$this->boundary.'XX'.MAILHEADER_EOL; $body .= 'Content-Type: multipart/related;'.MAILHEADER_EOL. - ' boundary="'.$this->boundary.'"'.MAILHEADER_EOL; + ' boundary="'.$this->boundary.'";'.MAILHEADER_EOL. + ' type="text/html"'.MAILHEADER_EOL; $body .= MAILHEADER_EOL; } |