PHP mail():标头出现在邮件正文中

发布于 2024-11-19 14:32:51 字数 581 浏览 1 评论 0原文

我目前正在 Linux 服务器上使用 php 开发邮件应用程序,但遇到问题。将电子邮件发送到具有不同客户端的一堆不同地址后,有时收件人无法阅读这些邮件。 例如,正文似乎以此开头:

boundary="=_2cac04098ebf51c342bd57eab2200e38"
Message-ID: <lo5huc.id4ip6qutsch.lforce.de>
Date: Mon, 11 Jul 2011 06:01:24 +0200 (CEST)

--=_2cac04098ebf51c342bd57eab2200e38

我真的不知道我的邮件发生了什么事。标头中的每一行均由 \n 分隔,边界条目有一个前导 \t。尽管客户端似乎在解析我的标头时读取了不存在的换行符。它也发生在标头的其他部分。

有人遇到过类似的问题吗?请帮我!

安迪

更新:我很确定这不是编码错误。我多年来一直在编写这个邮件内容(甚至编写了我自己的邮件客户端)并且它运行得很好。现在我们使用 RMAIL 类,它也来自一个更大的开源项目。我认为这更像是我的系统配置的问题......但这只是一个猜测。

I have a problem with a mailing application I'm currently developing with php on a linux server. After sending an email to a bunch of different addresses with different clients on it, sometimes these mails can't be read by the receivers.
For example the body appears to start with this:

boundary="=_2cac04098ebf51c342bd57eab2200e38"
Message-ID: <lo5huc.id4ip6qutsch.lforce.de>
Date: Mon, 11 Jul 2011 06:01:24 +0200 (CEST)

--=_2cac04098ebf51c342bd57eab2200e38

I really have no clue what's happening to my mails. Each line in the header is separated by \n, the boundary entry has a leading \t. Though the client seems to read a line break which is not there while parsing my header. It also happens in other parts of the header.

Has anyone ever had a similar problem? Please help me!

Andy

UPDATE: I'm pretty sure it's no coding error. I've been coding this mail stuff for years (even wrote my own mail client) and it worked perfectly. Right now we use the RMAIL class which is also from a bigger open source project. I think it's more like a problem with my system configuration... but that's just a guess.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

糖果控 2024-11-26 14:32:51

确保正确分隔每个标题行,例如:

<?php
   //To send HTML mail, the Content-type header must be set
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

   // Additional headers
   $headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
   $headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
   $headers .= 'Cc: [email protected]' . "\r\n";
   $headers .= 'Bcc: [email protected]' . "\r\n";

   // Mail it
   mail($to, $subject, $message, $headers);
?>

Make sure you seperate every header line correctly, for instance:

<?php
   //To send HTML mail, the Content-type header must be set
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

   // Additional headers
   $headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
   $headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
   $headers .= 'Cc: [email protected]' . "\r\n";
   $headers .= 'Bcc: [email protected]' . "\r\n";

   // Mail it
   mail($to, $subject, $message, $headers);
?>
简单 2024-11-26 14:32:51

我建议使用 PHPMailer,易于使用,可以处理所有必要的标头,轻松发送附件,多个收件人等。

http://phpmailer.worxware.com/index.php?pg=phpmailer

I suggest using PHPMailer, easy to use, takes care of all nesseccery headers, easy attachment sending, multiple recipients etc.

http://phpmailer.worxware.com/index.php?pg=phpmailer

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文