Ejemplo n.º 1
0
 public 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
 /**
  *  Quote any of the given addresses, if they need to be.
  */
 function quoteAnyAddressIfNecessary($address = array(), $charset = AK_ACTION_MAILER_DEFAULT_CHARSET)
 {
     foreach ($address as $k=>$v){
         $address[$k] = is_string($k) ?
         AkActionMailerQuoting::quoteAddressIfNecessary('"'.$k.'" <'.$v.'>', $charset) :
         AkActionMailerQuoting::quoteAddressIfNecessary($v, $charset);
     }
     return $address;
 }
Ejemplo n.º 4
0
 public function _getMessageHeaderFieldFormated($address_header_field)
 {
     $charset = empty($this->charset) ? AK_ACTION_MAILER_DEFAULT_CHARSET : $this->charset;
     return AkActionMailerQuoting::quoteAddressIfNecessary($address_header_field, $charset);
 }
Ejemplo n.º 5
0
 /**
  *  Quote any of the given addresses, if they need to be.
  */
 function quoteAnyAddressIfNecessary($address = array(), $charset = AK_ACTION_MAILER_DEFAULT_CHARSET)
 {
     foreach ($address as $k => $v) {
         $address[$k] = AkActionMailerQuoting::quoteAddressIfNecessary($v, $charset);
     }
     return $address;
 }
Ejemplo n.º 6
0
 function encode($text, $charset = 'utf-8')
 {
     return AkActionMailerQuoting::quotedPrintable($text, $charset);
 }
Ejemplo n.º 7
0
 function _getMessageHeaderFieldFormated($address_header_field)
 {
     $charset = empty($this->charset) ? AK_ACTION_MAILER_DEFAULT_CHARSET : $this->charset;
     return join(", ", AkActionMailerQuoting::quoteAnyAddressIfNecessary(Ak::toArray($address_header_field), $charset));
 }
Ejemplo n.º 8
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;
 }