Example #1
0
 public function testTo_Customized()
 {
     $mime = new \r8\Transform\MIME\Auto();
     $mime->setLineLength(30);
     $mime->setHeader("name");
     $mime->setOutputEncoding("UTF-8");
     $mime->setInputEncoding("UTF-8");
     $mime->setEOL("---");
     $this->assertSame("name: A sample string that---\twraps to a new line", $mime->to("A sample string that wraps to a new line"));
     $this->assertSame("name: =?UTF-8?Q?A=09sample=09?=---\t=?UTF-8?Q?string_that_wraps?=", $mime->to("A\tsample\tstring that wraps"));
     $this->assertSame("name: =?UTF-8?B?CUEJc3RyaW5n?=---\t=?UTF-8?B?CQ==?=", $mime->to("\tA\tstring\t"));
 }
Example #2
0
 /**
  * Returns the body string for an HTML
  *
  * @param \r8\Mail $mail The piece of mail whose body will be returned
  * @return String A formatted body email string
  */
 public function getBody(\r8\Mail $mail)
 {
     // If both the text and HTML are set...
     if ($mail->htmlExists() && $mail->textExists()) {
         $mime = new \r8\Transform\MIME\Auto();
         $mime->setEOL(self::EOL);
         $mime->setLineLength(self::LINE_LENGTH);
         $boundary = $mail->getBoundary();
         return "--" . $boundary . self::EOL . $mime->setHeader("Content-Type")->to('text/plain; charset="ISO-8859-1"') . self::EOL . $mime->setHeader("Content-Transfer-Encoding")->to('7bit') . self::EOL . self::EOL . $this->prepareContent($mail->getText()) . self::EOL . self::EOL . "--" . $boundary . self::EOL . $mime->setHeader("Content-Type")->to('text/html; charset="ISO-8859-1"') . self::EOL . $mime->setHeader("Content-Transfer-Encoding")->to('7bit') . self::EOL . self::EOL . $this->prepareContent($mail->getHTML()) . self::EOL . self::EOL . "--" . $boundary . "--" . self::EOL;
     } else {
         if ($mail->htmlExists()) {
             return $this->prepareContent($mail->getHTML());
         } else {
             return $this->prepareContent($mail->getText());
         }
     }
 }