减少通过SmtpClient()发送邮件的X-Spam点击量

时间:2021-06-26 18:14:49

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).

我用System.Net.Mail。SmtpClient通过远程SMTP服务器发送电子邮件。当我查看发送消息的头部时,我看到该消息从X-Spam中获得2.5点命中。如何防止From字段的base64编码,以及如何避免NULL_IN_BODY hit?即使它没有标记为垃圾邮件,我希望它是完美的。我找不到关于这个问题的任何信息(如果它真的是一个问题的话)。

MIME-Version: 1.0
From: Myself <no-reply@myself.com>
To: me@myself.com
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.

编辑:通过删除字段的所有编码,我设法删除了FROM_EXCESS_BASE64的警告,这是最重要的警告。我之前手动设置过编码。use UTF8字段。

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!

编辑:当删除除换行之外的所有控件-chars时,警告将返回!

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

1 个解决方案

#1


1  

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
  • 您已经对From header进行了base64编码,尽管没有必要这样做。SpamAssassin认为这可能是为了混淆某些东西: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.
  • 您的邮件主体中有二进制数据(特别是空字节)。例如,如果将UTF-16 (UTF-32)编码的文本转储到电子邮件的主体中,就会发生这种情况,因为普通的英语字符将分别表示为2(4)个字节,其中1(3)个字节为空。

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也会移除CR和LF字符('\r'和'\n')。更改代码以不删除它们,例如:

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

#1


1  

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
  • 您已经对From header进行了base64编码,尽管没有必要这样做。SpamAssassin认为这可能是为了混淆某些东西: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.
  • 您的邮件主体中有二进制数据(特别是空字节)。例如,如果将UTF-16 (UTF-32)编码的文本转储到电子邮件的主体中,就会发生这种情况,因为普通的英语字符将分别表示为2(4)个字节,其中1(3)个字节为空。

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也会移除CR和LF字符('\r'和'\n')。更改代码以不删除它们,例如:

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