脚本宝典收集整理的这篇文章主要介绍了php – 使用Zend_Mail时添加PDF附件,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
这非常奇怪,因为如果我直接从服务器或我的本地主机下载它,PDF会打开.
这是我用来发送附件的代码:
$htML = $view->render('email/invoice.phtml'); $mail = new Zend_Mail("utf-8"); $file = PubLIC_PATH . DS . 'data' . DS . $invoice . '.pdf'; $at = new Zend_Mime_Part(file_get_contents($file)); $at->filename = basename($file); $at->disposITion = Zend_Mime::DISPOSITION_ATTACHMENT; $at->encoding = Zend_Mime::ENCODING_8BIT; $mail->addAttachment($at); /* Here i add the attachment */ $mail->setBodyHtml($html); $mail->addTo($order->email,'Factura '. $invoice . ' '.Zend_Registry::get('siteName')); $mail->setFrom('vanzari@anunt.COM',Zend_Registry::get('siteName')); $mail->setSubject('Factura '. $invoice . ' '.Zend_Registry::get('siteName')); $mail->send();
$mail = new Zend_Mail(); $mail->setBodyHtml("description"); $mail->setFrom('id','name'); $mail->addTo(email,name); $mail->setSubject(subject); $content = file_get_contents("path to pdf file"); // e.g. ("attachment/abc.pdf") $attachment = new Zend_Mime_Part($content); $attachment->tyPE = 'application/pdf'; $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT; $attachment->encoding = Zend_Mime::ENCODING_BASE64; $attachment->filename = 'filename.pdf'; // name of file $mail->addAttachment($attachment); $mail->send();
以上是脚本宝典为你收集整理的php – 使用Zend_Mail时添加PDF附件全部内容,希望文章能够帮你解决php – 使用Zend_Mail时添加PDF附件所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。