The Simple Mail Transfer Protocol (SMTP) is an application layer protocol that allows the software to send electronic mail over the internet efficiently and reliably.
SMTP is based on a client-server model and uses TCP/IP for sending and receiving mails.
The original standard port for SMTP is Port 25.
An email is made up of two parts: a header and a body, both of which are separated by a null line. The real information to be read by the receiver is contained in the body. The header mostly comprises the topic of the email and the sender’s and recipient’s addresses.
SMTP requires a 7-bit ASCII format for all messages.
Working
The user-agent (UA) and mail transfer agent (MTA) are two components of the SMTP client and SMTP server. The user agent (UA) prepares the message, generates the envelope, inserts the message into it and MTA transfers the mail across the internet.
The client who wishes to send an email establishes a TCP connection with the SMTP server, which is always listening. The SMTP server initiates a connection to that port as soon as it listens for one. The client process sends the email immediately after successfully establishing a TCP connection. The mail is then transferred from the sender’s mail server to the recipient’s mail server using SMTP. Another protocol is required to retrieve mail from the receiver’s mail server to the receiver (commonly POP and IMAP)
When sending an email, SMTP is used twice: first to send the email from the sender to the sender’s mail server, and again to send the email from the sender’s mail server to the receiver’s mail server.