Ejemplo n.º 1
0
 public function attach($name, $data, $mimeType, $encoding = "base64", $followRFC2231 = false)
 {
     $file = new Sabel_Mail_Mime_File($name, $data, $mimeType, $followRFC2231);
     $file->setCharset($this->charset);
     $file->setEncoding($encoding);
     $file->setDisposition("attachment");
     $this->attachments[] = $file;
     return $this;
 }
Ejemplo n.º 2
0
 protected function _decodeMixedPart(Sabel_Mail_Mime_Content $content, $body)
 {
     if (($boundary = $content->getBoundary()) === "") {
         $message = __METHOD__ . "() Boundary Not Found.";
         throw new Sabel_Mail_Exception($message);
     }
     $parts = $this->splitByBoundary($body, $boundary);
     $mixed = array("body" => null, "html" => null, "attachments" => array(), "mails" => array());
     $notBodyPart = false;
     foreach ($parts as $partOfMessage) {
         $part = $this->createPart($partOfMessage);
         switch ($part->type) {
             case "multipart/alternative":
                 $alter = $this->_decodeAlternativePart($part->content, $part->body);
                 $mixed["body"] = $alter["body"];
                 $mixed["html"] = $alter["html"];
                 break;
             case "multipart/related":
                 $related = $this->_decodeRelatedPart($part->content, $part->body);
                 if ($related["body"] !== null) {
                     $mixed["body"] = $related["body"];
                 }
                 $mixed["html"] = $related["html"];
                 break;
             case "multipart/digest":
                 $mixed["mails"] = $this->_decodeDigestPart($part->content, $part->body);
                 break;
             case "text/html":
                 if (!$notBodyPart) {
                     $mixed["html"] = $this->createMimeObject($part);
                     break;
                 }
             case "text/plain":
                 if (!$notBodyPart) {
                     $mixed["body"] = $this->createMimeObject($part);
                     break;
                 }
             default:
                 $enc = $part->content->getEncoding();
                 $cset = $part->content->getCharset();
                 $data = $this->decodeString($part->body, $enc, $cset, false);
                 $file = new Sabel_Mail_Mime_File($part->content->getName(), $data, $part->type);
                 $file->setCharset($cset);
                 $file->setEncoding($enc);
                 $file->setDisposition($part->content->getDisposition());
                 $file->setHeaders($part->headers);
                 $mixed["attachments"][] = $file;
         }
         $notBodyPart = true;
     }
     return $mixed;
 }
Ejemplo n.º 3
0
 public function attach($name, $data, $mimeType = null, $encoding = "base64", $followRFC2231 = false)
 {
     if ($mimeType === null) {
         $mimeType = get_mime_type($data);
         if (!$mimeType) {
             $mimeType = "application/octet-stream";
         }
     }
     if (is_readable($data)) {
         $data = file_get_contents($data);
     }
     $file = new Sabel_Mail_Mime_File($name, $data, $mimeType, $followRFC2231);
     $file->setCharset($this->charset);
     $file->setEncoding($encoding);
     $file->setDisposition("attachment");
     $this->attachments[] = $file;
     return $this;
 }