A SMTP transactions consists of three command / reply sequences. They are:
- MAIL command. Establishes return address.
- RCPT command. Establishes recipient of message.
- DATA content of the message.
The Server responds to these commands uses status codes. The responses are positive (2xx reply codes) or negative. Negative replies can be permanent (5xx codes) or transient (4xx codes)
What is the difference between SMTP and POP and IMAP?
SMTP is really for sending messages. It cannot pull messages from a remote server on demand. You wanna read those messages sent to you that are on your email server. You need to use either the Post Office Protocol (POP) or Internet Message Access Protocol (IMAP).
So you wanna try it?
Ok, so you're sick of using email tools such as outlook for sending email messages. You wanna send your own messages?
- Open a command prompt.
- Type "telnet
- Talk to the server using SMTP.
It is possible to have Web Services over SMTP instead of HTTP. But it's more complex. Why? Because SMTP does not provide much flexibility to responses for requests. With HTTP a SOAP request message can be put into the HTTP message body. Similar a SOAP message can be put in the HTTP message body for a response. SMTP allows a SOAP message to be easily attached to the request. But not the response. A separate SMTP is required for the response.
So why why why would you ever want to use SMTP for sending SOAP messages? It might be:
- You cannot use HTTP because of firewalls
- The request / response model isn't desired by your application. You might just want something like publish / subscribe
- You web services are take a long time to run and you don't want situations where HTTP will time out on you.