System.Net.Mail 替代方案
我正在开发一个用 C# 编写的邮件服务器安排电子邮件的工具。我一直在使用 System.Net.Mail 类来发送邮件。
最近,我遇到了有关 RFC 违规和其他问题的各种问题,例如 SmtpClient 未根据协议结束 SMTP 会话。这些问题中的每一个都会导致较高的垃圾邮件分数并影响电子邮件传送,因此我需要解决这些问题。
我想知道其他人为了解决这些问题采取了什么措施。人们是否开始使用第三方组件,如果是的话,是哪一个?
编辑:作为支持证据,请参阅:http://www .codeproject.com/KB/IP/MailMergeLib.aspx
I'm working on a tool that schedules emails with our mail server in C#. I had been using the System.Net.Mail classes to send the mail.
Recently I've come across various issues with regards to RFC violations and other issues, such as SmtpClient not ending the SMTP session according to protocol. Each of these problems is counting toward a high spam score and affecting email delivery, so I need a solution to these problems.
I'm wondering what other people have resorted to in order to resolve these issues. Have people started using a third part component, if so which one?
EDIT: As supporting evidence, please see: http://www.codeproject.com/KB/IP/MailMergeLib.aspx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
一种替代方案是 MailKit。具有大量功能,可以通过
CancellationToken
可靠地取消发送,因此不存在问题SmtpClient
的 表示它不遵守指定的超时。NuGet 上也有大量下载。
甚至最近的文档 推荐它:
One alternative is MailKit. Has a ton of features, sending can be reliably cancelled via a
CancellationToken
, so it doesn't have the problem ofSmtpClient
that it doesn't respect the specified timeout.Has a lot of downloads on NuGet, too.
Even the recent documentation recommends it:
如果您有 Microsoft Exchange 2007 电子邮件服务器,那么您可以选择使用它的 网络发送电子邮件的服务方向。 Web 服务本身有点奇怪,但我们能够封装这种奇怪之处并使其像我们的 SMTP 类一样工作。
首先,您需要像这样引用 Exchange Web 服务:https://mail.yourwebserver.com/EWS/Services.wsdl" rel="nofollow noreferrer">https:// /mail.yourwebserver.com/EWS/Services.wsdl
这是一个示例:
If you have a Microsoft Exchange 2007 email server then you have an option to use it's web service direction to send email. The web service itself is a bit strange but we were able to encapsulate the weirdness and make it work just like our SMTP class.
First you would need to make a reference to the exchange web service like this: https://mail.yourwebserver.com/EWS/Services.wsdl
Here is an example:
我曾使用 SQL Server 在客户端桌面无法发送邮件(通常出于安全原因)但服务器可以的情况下发送电子邮件。
I have used SQL Server to send e-mail in situations where the client desktop was not able to send mail (usually for security reasons) but the server could.
SmtpClient 在 .NET 4.0 中进行了修改,以便它可以通过发送 QUIT 消息来正确关闭连接。此外,在 unicode 编码和长行长度折叠方面的标准合规性也得到了显着改进,因此您应该会发现,如果您切换到 .NET 4.0,您的垃圾邮件分数会下降。 .NET 4.0 Beta 2 中提供了折叠和编码修复,但您必须等到 .NET 4.0 RC 才能修复 QUIT 消息。此外,SmtpClient 现在将实现 IDisposable,以便您可以在发送完消息后确定地关闭您的 smtp 连接。这篇博文详细介绍了已做出的一些改进,尽管它没有讨论 SmtpClient 上的 IDisposable(应该是该博客上某个时候描述该更改的另一篇博文): http://blogs.msdn.com/ncl/存档/2009/08/06/what-s-new-in-system-net-mail.aspx
SmtpClient was modified in .NET 4.0 so that it properly closes connections by sending a QUIT message. In addition, significant improvements were made to standards compliance with respect to unicode encoding and folding of long line lengths so you should find that your spam scores go down if you switch to .NET 4.0. The folding and encoding fixes shipped in .NET 4.0 Beta 2 but you'll have to wait until .NET 4.0 RC to get the QUIT message fix. In addition, SmtpClient will now implement IDisposable so that you can deterministically close your smtp connections when you are finished sending messages. This blog post details some of the improvements that have been made although it doesn't talk about IDisposable on SmtpClient (should be another blog post on that blog at some point that describes that change): http://blogs.msdn.com/ncl/archive/2009/08/06/what-s-new-in-system-net-mail.aspx
Rebex Secure Mail 怎么样?
披露:我参与了这个库的开发。
What about Rebex Secure Mail?
Disclosure: I'm involved in development of this library.
Castle Email.Sender 组件?
Castle Email.Sender component?
我对这些组件很满意:QuikSoft
I have been happy with these components: QuikSoft
对于符合标准且广泛的邮件工具套件(以及其他 IETF 标准),我多次发现 /n software 的 IP*Works 是一个很好的 API。我在传入和传出场景中都使用过它。对于传出场景,我将其用于大型邮件发送支持,在我当前的项目中,我将其用于大规模 IMAP 邮件检索,以大量使用传入客户支持邮箱。我从未遇到过任何合规问题(到目前为止一切顺利)。
该套件不仅仅支持 IMAP 和 SMTP。它可以在此处找到,考虑到您所得到的东西,我发现成本是相当可以承受的为了你的钱。
For a standards compliant and broad suite of mail tools (and other IETF standards) I have several times found /n software's IP*Works to be a good API. I've used it in both incoming and outgoing scenarios. For the outgoing scenario, I used it for large mail-out support, and on my current project I use it for large scale IMAP mail retrieval for heavy use incoming customer support mailboxes. I've never had any compliance issues (so far so good).
The suite supports much more than just IMAP and SMTP. It can be found here, and I've found the cost to be quite bearable considering what you get for your money.