【问题标题】:After sending email a security warning comes in email body发送电子邮件后,电子邮件正文中会出现安全警告
【发布时间】:2017-05-15 13:54:18
【问题描述】:

我正在使用带有 PDF 附件的 php 邮件功能。这里一切正常,但在电子邮件正文中出现以下警告

“这封电子邮件有一个附件,打开时允许未经验证的脚本在您的计算机上运行。小心”

你能建议吗?有什么问题

【问题讨论】:

  • 它很可能是由您的邮件服务器或电子邮件程序添加的。您是否尝试过发送到其他地址?

标签: php email pdf


【解决方案1】:

您是否使用正确的标头来发送附件?

您可以尝试使用此模式(经过测试且有效):

$subject = 'SUBJECT';
$message .= 'Hello world'."\n";

$content = file_get_contents($file);
$content = chunk_split(base64_encode($content));

$separator = md5(time());
$eol = "\r\n";

$headers = "From: ME <me@mymail.org>".$eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol;
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol;

$body = "--".$separator.$eol;
$body .= "Content-Type: text/plain; charset=\"utf-8\"".$eol;
$body .= "Content-Transfer-Encoding: 8bit".$eol;
$body .= $message.$eol;

$body .= "--".$separator.$eol;
$body .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$body .= "Content-Transfer-Encoding: base64".$eol;
$body .= "Content-Disposition: attachment".$eol;
$body .= $content.$eol;
$body .= "--".$separator."--";

$filename 是您的附件,$file 是完整路径(包括 $filename)。

【讨论】:

    猜你喜欢
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-04
    • 2014-01-28
    • 1970-01-01
    • 2023-03-03
    相关资源
    最近更新 更多