【发布时间】:2014-11-03 12:46:00
【问题描述】:
我在使用 php 发送邮件时遇到换行问题。这里的主要问题是,换行符在带有附件的邮件中不起作用,但在纯文本中看起来不错。我们正在使用 IIS 服务器。
$filename = basename($file);
$file_size = filesize($file);
$content = chunk_split(base64_encode(file_get_contents($file)));
$uid = md5(uniqid(time()));
//$from = str_replace(array("\r", "\n"), '', $from); // to prevent email injection
$header = "From: FORM - test \r\n"
."MIME-Version: 1.0\r\n"
."Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"
."This is a multi-part message in MIME format.\r\n"
."--".$uid."\r\n"
."Content-type:text/plain; charset=iso-8859-1\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n"
.$message."
".$companyinfo."\r\n\r\n"
."--".$uid."\r\n"
."Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"
.$content."\r\n\r\n"
."--".$uid."--";
当我们在 Outlook 电子邮件客户端中看到它以段落类型显示时,其他客户端缺少换行符。有什么帮助吗?
【问题讨论】:
-
设置邮件类型,例如text/html,并把
<br />标签放在\n的地方。 -
可以在 Headers 部分使用
标签代替 \r\n 吗? -
用
试过了,但是没有区别
标签: php email formatting format sendmail