【发布时间】:2015-02-26 13:43:19
【问题描述】:
我正在使用 mime smtp 哟发送邮件。我的问题是邮件没有任何附件。我想发送带有附件的 pdf 邮件。 我的代码如下
$a = $fpdf->writeHTML($fpdf, true, false, true, false, '') ;
//$a = $fpdf->Output() ;
$host = 'smtp.ample.co.in';
$username = 'nasadnivas@aadsmple.co.in';
$password = 'asa3';
$to = "namadsivas@ampxle.co.in";
$from = "nadnivas@amsple.co.in";
$subject = "Attachments Test";
$filename = "test";
$headers = array(
'To' => $to,
'From' => $from,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array('host'=>$host, 'auth'=>true, 'username'=>$username, 'password'=>$password));
$text = "Plain Text Email Content";
$html = "HTML Email Content\n";
//$attachment = "mail_serinv.php?tchyear=2014&tchfyear=14&tchcid=001&tninvid=105466&tcpflag=I&tcnflag=L";
$mime = new Mail_mime();
$mime -> setTXTBody($text);
$mime -> setHTMLBody($html);
$mime -> addAttachment($a, 'text/plain',$filename,false);
$body = $mime -> get();
$headers = $mime -> headers($headers);
$mail = $smtp -> send($to, $headers, $body);
if(PEAR::isError($mail)) {
echo $mail->getMessage();
} else {
echo 'Message sent';
}
我搜索了很多链接,发现没用。请帮助我找到解决方案
【问题讨论】:
-
addAttachment是否返回成功/失败值?您能否将我们链接到该方法的文档?false在这里做什么? -
它显示了附件 test.php 与 0kb..no 数据