Пример #1
0
 /**
  * Adds a file attachment to this message
  * @param zibo\library\filesystem\File $attachment The file forthe attachment
  * @return string The name of the attachment MIME part
  */
 public function addAttachment(File $attachment)
 {
     $mime = Mime::getMimeType($attachment);
     $content = $attachment->read();
     $content = chunk_split(base64_encode($content));
     $part = new MimePart($content, $mime);
     $part->setEncoding(MimePart::ENCODING_BASE64);
     return $this->addPart($part, $attachment->getName());
 }
Пример #2
0
 /**
  * Adds a attachment to the body of the message
  * @param zibo\library\mail\MimePart $part The MIME part of the attachment
  * @param string $name The name of the attachment
  * @return null
  */
 private function addAttachmentToBody(MimePart $part, $name)
 {
     $this->body .= self::HEADER_CONTENT_TYPE . ': ' . $part->getMimeType() . '; name="' . $name . "\"\n";
     $this->body .= self::HEADER_CONTENT_DISPOSITION . ': attachment; filename="' . $name . "\"\n";
     $this->body .= self::HEADER_CONTENT_TRANSFER_ENCODING . ': ' . $part->getTransferEncoding() . "\n\n";
     $this->body .= $part->getBody() . "\n\n";
 }