Link to home
Start Free TrialLog in
Avatar of realcoding
realcodingFlag for United States of America

asked on

.net smtp listener

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

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.

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.
Avatar of kaufmed
kaufmed
Flag of United States of America image

Have you looked into the System.Net.Sockets.TcpListener class?
Avatar of realcoding

ASKER

kaufmed:

i have not worked with this class yet. can you explain how this would help me?
SOLUTION
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
P.S.

I arbitrarily used 8000 because our virus scanner at work is set up to block 25 by default. You can change it accordingly  : )
Here's the actual standard from the IETF, note section 4.5.1 lists the minimum required to comply with the standard.  You would probably need to meet those minimums to effectively work with commercial SMTP servers like Exchange.  There are also other details you need to be aware of (like maximum length for a "MAIL FROM:<>" command, and encoding of periods in message data).

http://tools.ietf.org/html/rfc821
@tgerbert

I started off looking at that, but after a few minutes I said, "Man, that's a lot to read!"

; )
Yeah, but most of it's not necessarily applicable - the list of minimum required commands is pretty short.
thanks all, i have got some serious reading to do. also ill try your POC app as well. thanks all for the great help !
NP. Glad to help  = )
@kaufmed,

I have the consul apps made but my environment is preventing mail from going out and telling me the server actively refused the connection. do i need to config something aside from running the apps?
>>  server actively refused the connection.

That usually means the server doesn't have that port open (i.e. the service isn't running). There could also be firewall or antivirus restrictions, I imagine. Can you confirm none of these is the case?