减少通过 SmtpClient() 发送的邮件上的 X-Spam 命中

发布于 2024-10-26 11:10:02 字数 1727 浏览 5 评论 0原文

我正在使用 System.Net.Mail.SmtpClient 通过远程 SMTP 服务器发送电子邮件。当我查看已发送邮件的标头时,我发现该邮件从 X-Spam 中获得了 2.5 次点击。如何防止 From 字段进行 Base64 编码,以及如何消除 NULL_IN_BODY 命中?尽管它没有被标记为垃圾邮件,但我希望它是完美的。我无法找到有关此问题的任何信息(如果这确实是一个问题)。

MIME-Version: 1.0
From: Myself <[email protected]>
To: [email protected]
Date: 25 Mar 2011 15:20:23 +0100
Subject: Test subject
Content-Type: text/plain; charset=us-ascii
X-Spam-Status: No, hits=0.5 required=5.0
X-Spam-Report: 0.5 hits, 5.0 required;
    * -0.5 ALL_TRUSTED            Passed through trusted hosts only via SMTP
    *  1.0 NULL_IN_BODY           FULL: Message has NUL (ASCII 0) byte in message
X-Virus-Scanned: by moam (http://www.moam.net/)
X-Moam-Version: 0.95
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by mx02.example.com id p2PEKKNs014451

Hello, sshow!
Below is your login information

Username: sshow
Password: a8sJdfl

Sent from http://me.myself.com

编辑:我设法通过删除该字段的所有编码来删除对 FROM_EXCESS_BASE64 的警告,这是最重要的警告。我之前曾为该字段手动设置 Encoding.UTF8

通过从 body 字符串中删除所有控制字符,它不再引发警告。但是,这也消除了换行符。

foreach (char c in body)
{
    stringBuilder.Append(Char.IsControl(c) ? ' ' : c);
}

编辑:当删除除换行符之外的所有控制字符时,警告会返回!

foreach (char c in body)
{
    stringBuilder.Append(Char.IsControl(c) && c != '\r' && c != '\n' ? ' ' : c);
}

I am using System.Net.Mail.SmtpClient to send e-mails through a remote SMTP server. When I'm looking at the headers of the sent message, I see that the message gets 2.5 hits from X-Spam. How can I prevent base64 encoding of the From field, and how to get rid of the NULL_IN_BODY hit? Even though it's not marked as spam, I want it to be perfect. I'm unable to find any information regarding this issue (if it really is an issue at all).

MIME-Version: 1.0
From: Myself <[email protected]>
To: [email protected]
Date: 25 Mar 2011 15:20:23 +0100
Subject: Test subject
Content-Type: text/plain; charset=us-ascii
X-Spam-Status: No, hits=0.5 required=5.0
X-Spam-Report: 0.5 hits, 5.0 required;
    * -0.5 ALL_TRUSTED            Passed through trusted hosts only via SMTP
    *  1.0 NULL_IN_BODY           FULL: Message has NUL (ASCII 0) byte in message
X-Virus-Scanned: by moam (http://www.moam.net/)
X-Moam-Version: 0.95
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by mx02.example.com id p2PEKKNs014451

Hello, sshow!
Below is your login information

Username: sshow
Password: a8sJdfl

Sent from http://me.myself.com

Edit: I managed to remove the warning for FROM_EXCESS_BASE64, which was the most important one, by removing all encoding for the field. I had previously manually set Encoding.UTF8 for the field.

By removing all control characters from body string, it no longer raises the warning. However, this also removes the line-breaks.

foreach (char c in body)
{
    stringBuilder.Append(Char.IsControl(c) ? ' ' : c);
}

Edit: When removing all control-chars except line-breaks, the warning returns!

foreach (char c in body)
{
    stringBuilder.Append(Char.IsControl(c) && c != '\r' && c != '\n' ? ' ' : c);
}

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

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

发布评论

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

评论(1

孤独患者 2024-11-02 11:10:02

如果没有看到电子邮件正文或源代码,则无法确定,但我假设以下情况是正确的:

  • 您已对 From 标头进行了 Base64 编码,尽管没有必要这样做。 SpamAssassin 认为这可能是混淆某些内容的尝试: http://wiki.apache.org/spamassassin/Rules /FROM_EXCESS_BASE64
  • 您的电子邮件正文中有二进制数据(特别是空字节)。例如,如果您将 UTF-16 (UTF-32) 编码文本转储到电子邮件正文中,则可能会发生这种情况,因为普通英文字符将表示为每个两(四)个字节,其中一(三)个字节为空。

如果这不能解决问题,请发布您的完整代码和整个消息的十六进制转储。

更新:

Char.IsControl 还删除 CR 和 LF 字符('\r' 和 '\n')。更改您的代码以不删除它们,例如:

Char.IsControl(c) && c != '\r' && c != '\n' ? ' ' : c

Without seeing the body of the email or the source code, it's not possible to say for sure, but I would assume the following are true:

  • You have base64 encoded the From header, even though it was not necessary to do so. SpamAssassin considers this a likely attempt to obfuscate something: http://wiki.apache.org/spamassassin/Rules/FROM_EXCESS_BASE64
  • You have binary data (specifically a null byte) in the body of your email. This can happen for example if you dump UTF-16 (UTF-32) encoded text into the body of the email, since ordinary English characters would be represented as two (four) bytes each, one (three) of which is null.

If that does not solve the issue, please post your full code and a hex dump of the whole message.

UPDATE:

Char.IsControl removes CR and LF characters as well ('\r' and '\n'). Change your code to not remove them, e.g.:

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