为了添加一个附件,你只是要建立一个新的监评部分,并添加这一信息。
例:
// 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。