English 中文(简体)
泽斯德邮2.0 Attachments
原标题:Zend Mail 2.0 Attachments

谁能向我提供某种实例,说明如何在ZF2邮递中添加附件?

我也这样做:

$message = new Message;
$message->setEncoding( utf-8 );
$message->setTo($email);
$message->setReplyTo($replyTo);
$message->setFrom($from);
$message->setSubject($subject);
$message->setBody($body);

but got stuck when needed to add an attachment. Thanks.

最佳回答

为了添加一个附件,你只是要建立一个新的监评部分,并添加这一信息。

例:

// create a new ZendMailMessage object
$message  = new Message;

// create a MimeMessage object that will hold the mail body and any attachments
$bodyPart = new MimeMessage;

// create the attachment
$attachment = new MimePart(fopen($pathToAttachment));
// or
$attachment = new MimePart($attachmentContent);

// set attachment content type
$attachment->type =  image/png ;

// create the mime part for the message body
// you can add one for text and one for html if needed
$bodyMessage = new MimePart($body);
$bodyMessage->type =  text/html ;

// add the message body and attachment(s) to the MimeMessage
$bodyPart->setParts(array($bodyMessage, $attachment));

$message->setEncoding( utf-8 )
        ->setTo($email)
        ->setReplyTo($replyTo)
        ->setFrom($from)
        ->setSubject($subject)
        ->setBody($bodyPart);  // set the body of the Mail to the MimeMessage with the mail content and attachment

这方面的一些有用的文件:ZF2 - Zendmail

问题回答

暂无回答




相关问题
Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

Tagging with Zend Framework

I m trying to create the same solutions as below, but using a simple MySQL query (instead of the static version used below where the words/tags are implemented in the code). The name of the MySQL ...

dynamicaly adding textboxes to zend_form

I hope that this is a quick question to answer. I am developing a form using Zend_Form, I have a number of Zend_Dojo_Form_Element_Textboxs to add to this form dynamically. These are added from rows ...

热门标签