What is SMTP? Everything you need to know

Comprehensive SMTP guide for sending and receiving email with the simple mail transfer protocol.

SMTP is an acronym for Simple Mail Transfer Protocol. It is an email protocol that is used to send emails from one email account to another over the Internet.

SMTP protocol

The email protocol is a set of rules that allow various email clients and accounts to easily send and receive information, and SMTP is one of the most common protocols alongside POP and IMAP. It is also the only dedicated protocol for sending emails. The clients such as Outlook, iCloud, Gmail, and Yahoo are relying on SMTP to "push" or send emails from the sender to the receiver.

What is an SMTP server?

Like different servers, an SMTP server is an application that serves clients on your network. In particular, the SMTP server handles sending, receiving, and forwarding emails. For example, consider server as a real post office. When you send a letter from City X to City Y, it will first reach the local post office in City X. Then it will proceed here and sent to the post office in City Y, which is in charge of delivery to the final destination. The same thing happens with the SMTP server. The process does not take a few days, but at most a few minutes. You may have come across the term SMTP port. These are the communication endpoints that handle the sending of email data over SMTP as it travels from one server to another over the network.

How does SMTP Works?

The best way to explain to use of SMTP is the rules and commands that drive it. These commands are also used to overcome the errors that can occur.

The basic commands to control SMTP is given below:

  • HELO or EHLO – This is an important command to start the entire email sending process. This command is used to start the conversation, and the server usually needs to send back a HELO command containing the domain name or IP address.
  • MAIL FROM: After the identify command, the sender passes this command that indicates who sent the email.
  • RCPT TO – The following command follows thousands of response codes that indicates where to send the email. It can come and go as many times as you like, depending on the number of people receiving the email.
  • Data – This will trigger a data transfer between the client and server. All message content is pushed to the SMTP server, which responds with a 345 response code. The content of the message is sent to the server, which sends a period of time on its own line to signal the end of the message.

SMTP error codes

Error codes in mailservers. What are they?

  • 4.X.X Persistent Transient Failure – These types of errors start with the code number "4", followed by two more numbers. This usually means that your email server is temporarily down. Repeating the command may fix the error, but these codes are often used by the server to keep untrusted senders away.
  • 5.X.X Permanent Error – These types of errors start with the code number "5", followed by two more numbers. This usually means that the SMTP connection has been lost.

How SMTP protocol is different from other email protocols

The main difference between these protocols is that SMTP is the only protocol for sending or "pushing" emails from one unknown email server to another. POP and IMAP are protocols for receiving or "fetching" receiver emails from your email server. Therefore, POP and IMAP limit the forwarding of email to only verified email servers. It cannot be used to communicate with the outside of your network.

Ready to dive in?Start building email applications today.