如何使用从PHP中获取的内容将HTML文件附加到电子邮件中?
问题描述:
如何通过PHP发送邮件的HTML文件的附件? - > HTML文件(代码)的内容在DB中以字符串形式存在。有一些简单的方法或免费的脚本来做到这一点?我不想存储文件localy做什么,我需要读出来DB和通俗易懂把它作为附件(不包括在体内)。如何使用从PHP中获取的内容将HTML文件附加到电子邮件中?
答
我喜欢梨。
<?
include('Mail.php');
include('Mail/mime.php');
$text = 'Text version of email';
$html = '<html><body>HTML version of email</body></html>';
$file = './files/example.zip';
$crlf = "rn";
$hdrs = array(
'From' => '[email protected]',
'To' => '[email protected]',
'Subject' => 'Test mime message'
);
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file,'application/octet-stream');
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail', $params);
$mail->send('[email protected]', $hdrs, $body);
?>
1为示例 – cletus 2009-01-20 01:14:56