Ejemplo n.º 1
0
 function test_quote_multibyte_chars()
 {
     $original = "æ ø and å";
     $result = AkActionMailerQuoting::quotedPrintableEncode($original);
     $unquoted = quoted_printable_decode($result);
     $this->assertEqual($unquoted, $original);
 }
Ejemplo n.º 2
0
 public function getBody()
 {
     if (!is_array($this->body)) {
         $encoding = $this->getContentTransferEncoding();
         $charset = $this->getCharset();
         switch ($encoding) {
             case 'quoted-printable':
                 return trim(AkActionMailerQuoting::chunkQuoted(AkActionMailerQuoting::quotedPrintableEncode($this->body, $charset)));
             case 'base64':
                 return $this->_base64Body($this->body);
             default:
                 return trim($this->body);
         }
     }
 }
Ejemplo n.º 3
0
 function toMail($defaults = array())
 {
     $Part =& new AkMail();
     list($real_content_type, $ctype_attrs) = $this->_getContentTypeAndAttributes();
     if (empty($this->parts)) {
         $Part->setContentTransferEncoding(!empty($this->transfer_encoding) ? $this->transfer_encoding : 'quoted-printable');
         switch (strtolower($this->transfer_encoding)) {
             case 'base64':
                 $Part->setBody(chunk_split(base64_encode($this->body)));
                 break;
             case 'quoted-printable':
                 $Part->setBody(AkActionMailerQuoting::chunkQuoted(AkActionMailerQuoting::quotedPrintableEncode($this->body)));
                 break;
             default:
                 $Part->setBody($this->body);
                 break;
         }
         // Always set the content_type after setting the body and or parts!
         // Also don't set filename and name when there is none (like in
         // non-attachment parts)
         if ($this->content_disposition == 'attachment') {
             unset($this->ctype_attrs['charset']);
             $Part->setContentType($real_content_type, null, array_diff(array_merge(array('filename' => $this->filename), $ctype_attrs), array('')));
             $Part->setContentDisposition($this->content_disposition, array_diff(array_merge(array('filename' => $this->filename), $ctype_attrs), array('')));
         } else {
             $Part->setContentType($real_content_type, null, $ctype_attrs);
             $Part->setContentDisposition($this->content_disposition);
         }
     } else {
         if (is_string($this->body)) {
             $Part->setBody($this->body);
             $Part->setContentType($real_content_type, null, $ctype_attrs);
             $Part->setContentDisposition('inline');
             $this->setPart($Part);
         }
         foreach (array_keys($this->parts) as $k) {
             $SubPart = strtolower(get_class($this->parts[$k])) != 'akmail' ? $this->parts[$k]->toMail($defaults) : $this->parts[$k];
             $Part->setPart($SubPart);
         }
         if (stristr($real_content_type, 'multipart')) {
             $Part->setContentType($real_content_type, null, $ctype_attrs);
         }
     }
     $Part->addHeaders($this->header);
     return $Part;
 }