附件
使用createAttachment()方法可以将文件附加到邮件中。Zend_Mail会缺省地认为该文件是二进制对象(application/octet-stream),以 base64编码传输, 并且作为邮件的附件处理。通过传递额外的参数给createAttachment()方法可以覆盖上述缺省设定:
带附件的邮件
createAttachment($someBinaryString);
$mail->createAttachment($myImage, 'image/gif', Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_8BIT);]]>
如果你想得到对此附件MIME段产生的更多控制,你可以使用createAttachment()方法的返回值来修改它的属性。方法createAttachment()返回了一个Zend_Mime_Part对象:
createAttachment($myImage);
$at->type = 'image/gif';
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding = Zend_Mime::ENCODING_8BIT;
$at->filename = 'test.gif';
$mail->send();]]>
创建 Zend_Mime_Part 实例和用 addAttachment() 添加它的替代方案:
type = 'image/gif';
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding = Zend_Mime::ENCODING_8BIT;
$at->filename = 'test.gif';
$mail->addAttachment($at);
$mail->send();]]>