Click here to Skip to main content
15,123,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

We have 2 servers running our application. All the information between the 2 servers would be sent as SMTP messages so that they can be scanned by a email scanner. So we are into developing C# components to send and receive emails.

As far as send emails .Net framework provides built in SMTP client to send messages but the issue we are facing is to receive the messages using s socket listener. When a socket is bound to port to which smtpclient.send(message); is sent, it is receiving nothing. Shouldn't it receive the message as a stream? What are we missing?
Nicholas Marty 15-Nov-13 6:43am
If you connect e.g. with the telnet client (or any other tcp client) to the server. Are you receiving anything? Maybe you're missing an "AcceptSocket" or "AcceptClient" call ore something like that on the server. In addition SMTP isn't just sending the whole message from the client to the server. An e-mail sent over smtp contains multiple messages where the server has to report with a status code.
Richard MacCutchan 15-Nov-13 9:39am
You need to study the SMTP RFC in order to handle SMTP communications. It is not a simple socket receive operation.
Tamil89 16-Nov-13 1:17am
Thanks for your replies

Using socket SMTP we received EHLO , mail from and rcpt to successfully but we are facing issue in reading the data received .Any comment regarding this would be helpful
Richard MacCutchan 16-Nov-13 4:45am
but we are facing issue in reading the data received .Any comment regarding this would be helpful
We cannot guess what issues you may be facing. Please edit your question and provide proper details.

1 solution

Instead of writing a SMTP server, use an existing mail server like :[^] and setup email accounts for your servers on that mail server.

To read from a POP3 server see this : POP3 Email Client with full MIME Support (.NET 2.0)[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900