.NET SMTP侦听NET、SMTP

2023-09-03 08:07:42 作者:外貌協會的會長

有没有办法使用.NET创建一个控制台应用程序。或服务在某个端口监听SMTP邮件?

Is there a way for using .net to create a console app. or service to listen for SMTP messages over a certain port?

我需要建立一个中间层对象,将捕获并处理SMTP邮件。也就是说,我想SMTP邮件发送,并拾起该侦听器,然后分解为它的基本组成部分,并保存到一个SQL Server数据库。

I need to create a middle tier object that will capture and process smtp messages. That is to say i want smtp messages sent and picked up by this listener and then broken down to its basic components and persisted to a sql server DB.

如果有现成的溶液,甚至更好。我没能找到一个像我忙不迭​​网络。

If there is a off the shelf solution even better. I was not able to find one as I scurried the web.

请注意:SMTP发送者将网络上的Web应用程序,以及交流。该监听器将被分配一些端口,该端口上的所有SMPT流量将被指定为我的具体应用。

Note: smtp sender will be a web app on the network, as well as exchange. The listener will be assigned some port so all smpt traffic on this port will be designated for my particular application.

推荐答案

我不知道它有多好,但有一个的 SMTP服务器的例子的为$ C $的CProject。

I don't know how good it is, but there's an SMTP server example at CodeProject.

什么你问的是超过监听SMTP邮件。 SMTP是一个双向通信协议。发送电​​子邮件涉及到客户端和服务器之间传递多个数据包。我不建议尝试自己写一个,除非你没有什么好做。

What you're asking for is more than "listening for SMTP messages." SMTP is a two-way communication protocol. Sending an email involves multiple packets being passed between client and server. I wouldn't recommend trying to write one yourself unless you don't have anything better to do.

我建议你看看自带的IIS中的SMTP模块。这将提供电子邮件,在文件系统中的目录,而你的程序可以监视和处理。

I'd suggest that you take a look at the SMTP module that comes with IIS. It will deliver emails to a directory in the file system, which your program can monitor and process.