<?php
$message=$_POST['feedback'];
$attachments=$_POST['file'];
$subject=$_POST['subject'];
$tosend=$_POST['to'];
$tocc=$_POST['cc'];
$mail = new Zend_Mail();
$mail->setFrom('user@example.com','Admin');
$mail->addTo($tosend, 'Some Recipient');
$mail->addCc($tocc);
$mail->setType(Zend_Mime::MULTIPART_RELATED);
$mail->setSubject($subject);
$mail->setBodyHtml($message);
$attachments = $mail->createAttachment(file_get_contents($attachments));
$attachments->type = '.txt';
$attachments->filename = "";
$mail->send($transport);
?>使用这段代码我不能打开文件,它只接受文件名而不是整个路径来打开附件,当我点击打开附件时,它给出的错误是无法打开流。
这段代码可以很好地与cc、Bcc等其他特性协同工作。
发布于 2013-11-26 19:47:09
$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(); https://stackoverflow.com/questions/20211314
复制相似问题