public function sendEmail($from, $to, $cc, $subject, $body, $attachmentFilename)
 {
     $message = new Message();
     $message->setFrom($from);
     $message->setTo($to);
     $message->setCc($cc);
     $message->setSubject($subject);
     $mimeMessage = new \Zend\Mime\Message();
     $part = new \Zend\Mime\Part($body);
     $part->setType(Mime::TYPE_TEXT);
     $part->setCharset('UTF-8');
     $mimeMessage->addPart($part);
     $part = new \Zend\Mime\Part('<p>' . $body . '<p>');
     $part->setType(Mime::TYPE_HTML);
     $part->setCharset('UTF-8');
     $mimeMessage->addPart($part);
     $part = new \Zend\Mime\Part($body);
     $part->setType(Mime::TYPE_OCTETSTREAM);
     $part->setEncoding(Mime::ENCODING_BASE64);
     $part->setFileName($attachmentFilename);
     $part->setDisposition(Mime::DISPOSITION_ATTACHMENT);
     $mimeMessage->addPart($part);
     $message->setBody($mimeMessage);
     $this->transport->send($message);
     $this->debugSection('ZendMailer', $subject . ' ' . $from . ' -> ' . $to);
 }
示例#2
0
 function addAttachment($data, $filename, $mimetype)
 {
     $body = $this->mail->getBody();
     if (!$body instanceof \Zend\Mime\Message) {
         $this->convertBodyToMime($body);
         $body = $this->mail->getBody();
     }
     $attachment = new Zend\Mime\Part($data);
     $attachment->setFileName($filename);
     $attachment->setType($mimetype);
     $attachment->setEncoding(Zend\Mime\Mime::ENCODING_BASE64);
     $attachment->setDisposition(Zend\Mime\Mime::DISPOSITION_INLINE);
     $body->addPart($attachment);
 }