Simple Mail Transfer Protocol(SMTP)

August 23, 2008

About SMTP

SMTP it’s a simple protocol used for sending electronic messages on internet.SMTP use the 25 TCP port and obtain the address of a SMTP sever using a MX(Mail Exchange) record from the DNS server configuration.

The SMTP protocol specify the way that a electronic message is transfered between SMTP process that are on different systems.The SMTP process that initiate the transfer is called client and the SMTP process that receive that process is called SMTP server. It’s not so important here the way that the message is sent from the client to the server or the way that the server send the message to destination.

History

SMTP protocol was used especially at the begin of ‘80 years. That tine it was used less than UUCP(Unix to Unix CoPy) because that was just perfect for sending messages between systems permanently connected. Anyway SMTP works better for sending electronic messages when the client and the server are permanently connected to a network. First program that implemented the SMTP protocol was Sendmail. From 2001 on there was other programs that implemented that protocol: Postfix, Qmail, Novell, GroupWise, Exim, NetMail and Microsoft_Exchange_Server.

How it works…

Communications between client and server is done using ASCII texts.Initially the client establish the connection with the server and wait for server responding with “220 Service Ready”. From any reasons the server can send this message lately.When the client receive that 220 message he sent a HELLO command and that way he is unfolding his identity.When the connection was establish the client can send one or more messages, can close the connection or can user other services like verifying the mail adress. The server must respond after each command indicating this way that the command was accepted or if there are errors.

For sending a message the client use the MAIL command for specifying the client address. If this command is ok the server respond with “250 ok” message. Then the client send RCPT command for specifying the receiver address. The server respond with “550 No such user here”, or “250 OK”, depending by command validity.When the server accept the command the client send DATA command and that means that the client is starting sending the message content.In this moment server can respond with “503 Command out of sequence” or “554 No valid recipients” message. If server respond with “354 Start mail input” message then the client can start sending the message content. The end of the message will be tagged by <CR><LF>.<CR><LF>.

A SMTP sever must know:

- HELO - the client identity

- EHLO - client identity by large request

- MAIL FROM - client specification

- RCPT TO - receiver specification

- DATA - message content

- RSET - reset

- QUIT -finish the session

- HELP - help for command

- VRFY - verifying an address

- EXPN - expanding an address

- VERB - detailed informations

The function of the SMTP protocol can be tested by initiating a TCP connection using a telnet client:

telnet mailhost.domeniu.ro 25
Server: 220 mailhost.domeniu.ro ESMTP
Client: HELO host.domeniu.ro
Server: 250 Hello host.domeniu.ro
Client: MAIL FROM: user@domeniu.ro
Server: 250 Ok
Client: RCPT TO: user@altdomeniu.ro
Server: 250 Ok
Client: DATA
Server: 354 End data with <CR><LF>.<CR><LF>
Client: Subject: test
Client: un mesaj test
Client: .
Server: Mail queued for delivery.
Client: QUIT
Server: 221 Closing connection. Bye.

 

Post a comment

Name (required)

Mail (will not be published) (required)

Website

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word