Magento使用带有附件的Zendu邮件轻松发送电子邮件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Magento使用带有附件的Zendu邮件轻松发送电子邮件相关的知识,希望对你有一定的参考价值。
send mail with attached fileexamples: http://framework.zend.com/svn/framework/standard/trunk/tests/Zend/Mail/MailTest.php
in magento there is no available methods for attach file. once we do it in magento by adding a following code public function addAttachment(Zend_Pdf $pdf){ $file = $pdf->render(); $attachment = $this->getMail()->createAttachment($file); $attachment->type = 'application/pdf'; $attachment->filename = 'yourfile.pdf'; } for this u need to do following. try{ $mail = new Zend_Mail(); $mail->setFrom("fromemail","fromname"); $mail->addTo("toemail","toname"); $mail->setSubject("subject"); // this is for to set the file format $at = new Zend_Mime_Part($content); $at->type = 'application/csv'; // if u have PDF then it would like -> 'application/pdf' $at->disposition = Zend_Mime::DISPOSITION_INLINE; $at->encoding = Zend_Mime::ENCODING_8BIT; $at->filename = $filename; $mail->addAttachment($at); $mail->send(); }catch(Exception $e) { echo $e->getMassage(); }
以上是关于Magento使用带有附件的Zendu邮件轻松发送电子邮件的主要内容,如果未能解决你的问题,请参考以下文章