Avatar of realcoding
realcoding
Flag 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.
C#ExchangeEmail Clients

Avatar of undefined
Last Comment
kaufmed

8/22/2022 - Mon
kaufmed

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

ASKER
kaufmed:

i have not worked with this class yet. can you explain how this would help me?
SOLUTION
Todd Gerbert

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
kaufmed

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
kaufmed

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  : )
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Todd Gerbert

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
kaufmed

@tgerbert

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

; )
Todd Gerbert

Yeah, but most of it's not necessarily applicable - the list of minimum required commands is pretty short.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
realcoding

ASKER
thanks all, i have got some serious reading to do. also ill try your POC app as well. thanks all for the great help !
kaufmed

NP. Glad to help  = )
realcoding

ASKER
@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?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
kaufmed

>>  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?