mime 格式的文件在出现换行符时会丢失点

发布于 2024-12-12 00:57:49 字数 1271 浏览 0 评论 0原文

我正在编写一个包含 html 的 mime 格式的电子邮件文件。我正在编写 mime 文件的 html 部分,如下所示:

writer.WriteLine("--" + altBoundary);
writer.WriteLine("Content-Type: text/html; charset=\"UTF-8\"");
writer.WriteLine("Content-Transfer-Encoding: quoted-printable");
writer.WriteLine();
QuotedPrintableEncoder qpEncoder=new QuotedPrintableEncoder();
writer.WriteLine(qpEncoder.Encode(HTMLBody));

在 HTMLBody 中,我有一大块 html。其中一个片段如下所示:

<p><br />Dear Ben,<br /><br />

              Thank you for your interest in our products and services.
   =
          =20
              </p>

              <p>Here are some literature links you may find interesting:<=
/p>

              <ul><li><a  title=3D"Brochure One"  href=3D"http://xxxxxshow=
.xxxpoint.com/Document?client=3DXxxxxxpoint&document=3DBrochure One">Broch=
ure One</a></li></ul>

              Regards,<br />

请注意 //xxxxxshow.xxxpoint.com 域,它跨越 mime 文件中的换行符。当此域到达 Outlook 时,它“丢失了第一个点”,因此它读取的是 xxxxshowxxxpoint.com,而它应该读取的是 xxxxxshow.xxxpoint.com。如果发生换行,使得该点成为下一行的第一个字符,则该点会“丢失”,并且当电子邮件到达 Outlook 时,该点会从电子邮件源中丢失。如果换行符出现在“xxxxxshow”一词的中间,则该点不会丢失,并且它确实会出现在 Outlook 内的电子邮件中。

这是怎么回事?我该如何解决这个问题?

I am writing a mime-formatted email message file containing html. I am writing the html portion of the mime file as follows:

writer.WriteLine("--" + altBoundary);
writer.WriteLine("Content-Type: text/html; charset=\"UTF-8\"");
writer.WriteLine("Content-Transfer-Encoding: quoted-printable");
writer.WriteLine();
QuotedPrintableEncoder qpEncoder=new QuotedPrintableEncoder();
writer.WriteLine(qpEncoder.Encode(HTMLBody));

In the HTMLBody I have a large chunk of html. One fragment of this looks as follows:

<p><br />Dear Ben,<br /><br />

              Thank you for your interest in our products and services.
   =
          =20
              </p>

              <p>Here are some literature links you may find interesting:<=
/p>

              <ul><li><a  title=3D"Brochure One"  href=3D"http://xxxxxshow=
.xxxpoint.com/Document?client=3DXxxxxxpoint&document=3DBrochure One">Broch=
ure One</a></li></ul>

              Regards,<br />

Note the //xxxxxshow.xxxpoint.com domain, which spans a line break in the mime file. When this domain arrives in Outlook it has 'lost the first dot, so it reads xxxxshowxxxpoint.com, whereas it should read xxxxxshow.xxxpoint.com. If a line break occurs so that the dot is the very first character on the next line, the dot gets 'lost', and is missing from the source of the email when it arrives in Outlook. If the line break occurs half-way through the word 'xxxxxshow' then the dot does not get lost, and it does appear in email within outlook.

What is going on, and how do I fix this?

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

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

发布评论

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

评论(1

姐不稀罕 2024-12-19 00:57:49

这看起来您没有正确编码 SMTP 的电子邮件文本。 来自维基百科

由于消息正文可以包含仅包含句点的行作为文本的一部分,因此每次以句点开头的行,客户端都会发送两个句点;相应地,服务器将行开头的两个句点的每个序列替换为单个句点。这种转义方法称为点填充

基本上,每当您想在行首写一个句点时,您都​​必须写两个句点。

This looks like you're not encoding the text of the e-mail for SMTP correctly. From Wikipedia:

Since a message body can contain a line with just a period as part of the text, the client sends two periods every time a line starts with a period; correspondingly, the server replaces every sequence of two periods at the beginning of a line with a single one. Such escaping method is called dot-stuffing.

Basically, whenever you want to write a period at the start of a line, you have to write two periods instead.

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