“\n”收不到 OUTLOOK 电子邮件

发布于 2024-11-28 19:15:15 字数 219 浏览 1 评论 0原文

$str = "Hello Jagdish \n\n";
$str .= "this is nice evening \n\n";
$str = stripcslashes($str);
mail($to, $subject, $message);

在 Outlook 中查看此电子邮件时,没有出现“\n\n”
原因是什么?
如何在电子邮件中获取这些内容?

$str = "Hello Jagdish \n\n";
$str .= "this is nice evening \n\n";
$str = stripcslashes($str);
mail($to, $subject, $message);

when checking this email in the outlook no "\n\n" is coming in that
what is the reason ?
how to get those in the email ?

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

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

发布评论

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

评论(4

心如荒岛 2024-12-05 19:15:15

Outlook 会根据需要重新设置纯文本电子邮件的格式。可以在选项中关闭此功能,但如果您以纯文本形式向客户发送内容,则对此无能为力。

其理论是,它试图检测固定宽度的列,并删除固定宽度,以使电子邮件更具可读性。根据我的经验,这只会产生烦恼,正如您所经历的那样。

如果您要发送电子邮件的 HTML 版本,它将被正确使用和格式化。 (请注意,对于无法使用 HTML 版本的客户端,除 HTML 版本外,您还应始终发送纯文本版本。Outlook 默认情况下使用 HTML 版本(如果存在)。)

Outlook re-formats plain-text e-mails as it sees fit. This can be turned off in the options, but if you are sending stuff to your customers in plain-text, there is nothing that can be done about this.

The theory is that it is trying to detect a fixed-width column, and remove the fixed-width so the e-mail is more readable. In my experience, this simply produces annoyance, as you are experiencing.

If you were to send an HTML version of your e-mail, it would be used and formatted correctly. (Note that you should always send a plain-text version in addition to the HTML version, for clients that can't use the HTML version. Outlook uses the HTML version by default, if it exists.)

当梦初醒 2024-12-05 19:15:15

Outlook 会自动删除纯文本电子邮件中的换行符。

如果确实如此,它会告诉您(至少 Outlook 2003 是这样),并且您可以选择恢复它们。

Outlook removes linebreaks automatically in plain text e-mails.

If it does, it tells you so (well, at least Outlook 2003 did) and you got the option to restore them.

负佳期 2024-12-05 19:15:15

我在使用 \n 和生成纯文本电子邮件时遇到了同样的问题(在 Java 中)。这很烦人,因为对我来说使用 2 \n 添加了两行新行,所以我可以做零或两行新行,但不能做一行。

我尝试了 \r\n 但似乎没有成功。

我想出了一个解决我问题的方法。我只是在行尾之后和 \n 之前添加了一堆空格。我发现我需要 3 个空间才能正常工作。

body += "单词单词单词\n";

因为我的行有 57 个字符长(不含空格),所以我假设 Outlook 合并了少于 60 个空格的行 (57 + 3 = 60)。 Outlook 让我这样做很糟糕,但它对我有用!

I'm having the same issue (in Java) generating plain text emails using \n and. It was annoying because using 2 \n's for me added both new lines, so I could do zero or two new lines but not one.

I tried \r\n but it didn't seem to do the trick.

I figured out a hack that fixed my problem. I just added a bunch of spaces after the end of the line and before the \n. I figured out that I needed exactly 3 spaces for it to work.

body += "words words words \n";

Because my line was 57 chars long without the spaces, I'm assuming that outlook is combining lines that have less than 60 spaces (57 + 3 = 60). Outlook is terrible for making me do this but it worked for me!

装迷糊 2024-12-05 19:15:15

Windows 使用 \r\n 换行符,请尝试将每个 \n 替换为 \r\n
另外,您需要删除 $str = stripcslashes($str); 因为它将 \n 转换为 n

Windows uses \r\n line breaks, try replacing every \n with \r\n.
Also, you need to remove $str = stripcslashes($str); as it converts \n into n

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