Fix SMTP delivery of email containing <CRLF>.<CRLF>
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 14 Apr 2014 14:37:24 +0000 (16:37 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 28 Apr 2014 19:17:12 +0000 (21:17 +0200)
wcfsetup/install/files/lib/system/mail/SMTPMailSender.class.php

index 3c606b56b12c254879ab95652945d9e9be244234..772903b191dc966ee617b7f8f67672592c2dc7cd 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\system\mail;
 use wcf\system\exception\SystemException;
 use wcf\system\io\RemoteFile;
+use wcf\util\StringUtil;
 
 /**
  * Sends a Mail with a connection to a smtp server.
@@ -193,7 +194,15 @@ class SMTPMailSender extends MailSender {
                
                $this->write($header);
                $this->write("");
-               $this->write($mail->getBody());
+               $lines = explode(Mail::$lineEnding, $mail->getBody());
+               foreach ($lines as $line) {
+                       // 4.5.2 Transparency
+                       // o  Before sending a line of mail text, the SMTP client checks the
+                       //    first character of the line.  If it is a period, one additional
+                       //    period is inserted at the beginning of the line.
+                       if (StringUtil::startsWith($line, '.')) $line = '.'.$line;
+                       $this->write($line);
+               }
                $this->write(".");
                
                $this->getSMTPStatus();