<?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);
?>
使用这段代码时,我无法打开文件,它只获取文件名而不是完整路径以打开附件。当我点击打开附件时,会出现“无法打开流”的错误。
但是,这段代码在其他功能如抄送、密送等方面运行良好。