减少通过 SmtpClient() 发送的邮件上的 X-Spam 命中
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有看到电子邮件正文或源代码,则无法确定,但我假设以下情况是正确的:
如果这不能解决问题,请发布您的完整代码和整个消息的十六进制转储。
更新:
Char.IsControl 还删除 CR 和 LF 字符('\r' 和 '\n')。更改您的代码以不删除它们,例如:
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:
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.: