What is SMTP? The protocol that sends every email
SMTP is the part of email you never see: the set of rules every mail app and mail server uses to hand a message on until it reaches the right inbox.
SMTP (Simple Mail Transfer Protocol) is the standard way email is sent: from your email app to your provider's server, and from server to server across the internet until it reaches the recipient's provider. Apps send on port 587 or 465; servers talk to each other on port 25. Reading your mail uses a different protocol, IMAP or POP3.
What SMTP stands for
SMTP stands for Simple Mail Transfer Protocol. It was first published in 1982 and is defined today in RFC 5321. Every email service uses it, from Gmail and Outlook to the server behind a small business website.
A common typo is "SMPT". The correct order is S-M-T-P: Simple Mail Transfer Protocol.
How an email travels
- You press Send. Your email app connects to your provider's outgoing (SMTP) server, usually on port 587 or 465, and signs in with your username and password.
- Your provider looks up the recipient. It reads the part after the @ and checks that domain's MX record in DNS to find which server accepts its mail.
- Server talks to server. Your provider connects to that server on port 25 and passes the message on, using SMTP commands such as
MAIL FROM,RCPT TOandDATA. - The receiving server answers with a code. A
250means accepted. A code starting with 4 means "try again later", and one starting with 5 means a permanent failure, which comes back to you as a bounce. - The recipient reads it. Their app downloads the message with IMAP or POP3, not SMTP.
Want to see the actual commands? Read an SMTP conversation explained step by step.
SMTP ports: 25, 587 and 465
| Port | Used for | Notes |
|---|---|---|
587 | Sending from an app (submission) | Starts plain, then upgrades to encryption with STARTTLS. The usual choice. |
465 | Sending from an app (submission) | Encrypted from the first byte (implicit TLS). Also a good choice. |
25 | Server to server | Many home internet providers block it for outgoing mail to stop spam. |
2525 | Sending services | Not an official port, but some sending services offer it when 587 is blocked. |
See TLS vs STARTTLS for the difference between 465 and 587.
SMTP vs IMAP vs POP3
| Job | Common ports | |
|---|---|---|
| SMTP | Sends mail | 587, 465, 25 |
| IMAP | Reads mail and keeps it in sync on every device | 993 |
| POP3 | Downloads mail to one device | 995 |
That is why setting up an email account by hand asks for two servers: an incoming one (IMAP or POP3) and an outgoing one (SMTP). More detail in email ports: IMAP, POP3 and SMTP.
Finding your SMTP server settings
Your provider runs the SMTP server; you only enter its details where an app, printer or website asks for them. For Gmail it is smtp.gmail.com on port 465 or 587, signed in with your full address and usually an app password. Full details are in Gmail SMTP settings, and other providers are listed in email server settings.
SMTP error codes
Every SMTP reply starts with a three-digit code. 2xx means success, 4xx means a temporary problem the sender will retry, and 5xx means a permanent failure, such as 550 5.1.1 for an address that does not exist. Look up any code in the SMTP error code library.
Questions people ask
- Is SMTP secure?
- SMTP itself sends text in the clear, so modern servers add encryption: STARTTLS on port 587 or implicit TLS on port 465. Server-to-server mail is usually encrypted with STARTTLS too, but that depends on both servers supporting it.
- Do I need my own SMTP server?
- Usually not. Your email provider already runs one. You only need SMTP details when you connect an app, a printer or a website contact form so it can send mail through your account.
- What is an SMTP relay?
- A server that accepts mail and passes it on to its destination. Sending services such as those used for newsletters are SMTP relays. An "open relay" that passes on mail for anyone is a security problem and gets blocked quickly.
- Is SMTP the same as email?
- No. SMTP is the delivery part of email. Storing and reading messages is handled by IMAP or POP3, and the message format itself is defined separately.