SMTP stands for Simple Mail Transfer Protocol. It is the standard way email is sent: your mail app or website hands a message to an SMTP server, and SMTP servers pass it on from one to the next until it reaches the server that holds the recipient's mailbox. SMTP only moves mail forward. Reading mail from a mailbox uses different protocols, IMAP or POP3.
SMTP is old, text based and still in daily use. The current specification is RFC 5321, and modern additions such as TLS encryption and authentication are layered on top. This guide covers what SMTP does, the ports it uses, a sample conversation, and where it fits next to the other mail protocols.
What SMTP does
SMTP has one job: take a message and its list of recipients from a sender and deliver it to the next system that will accept responsibility. It does not store mail for you to read, it does not sort your inbox, and it has no idea whether a person will ever open the message. A message may pass through several SMTP servers on its way, each adding a Received header, which is why headers are the main tool for tracing delivery. See Received headers.
How a message travels
- Compose. You write the message in a mail client, a website or an application, called the mail user agent.
- Submit. The client connects to your outgoing SMTP server, authenticates and hands over the message. This server is the mail submission agent.
- Look up. The sending server reads the recipient domain's MX records in DNS to find which server accepts its mail. See MX records.
- Transfer. The sending server, acting as a mail transfer agent, opens an SMTP connection to that server, usually on port 25, and sends the message.
- Accept and store. The receiving server checks the message and passes it to a delivery agent that places it in the recipient's mailbox.
- Read. The recipient's client fetches it with IMAP or POP3, or shows it in webmail.
If the next server is unavailable, the sending server keeps the message in a queue and retries, often for days, before returning a bounce to the sender. Details are in how email works and mail transfer agents.
SMTP ports
| Port | Used for | Encryption |
|---|---|---|
| 25 | Server to server delivery between mail transfer agents | Opportunistic STARTTLS; many networks block outbound traffic on this port |
| 587 | Message submission from clients and applications (RFC 6409) | STARTTLS upgrade, authentication required |
| 465 | Message submission over implicit TLS (RFC 8314) | TLS from the first byte |
| 2525 | Not an official port; some providers offer it as an alternative when 587 is blocked | Provider dependent |
For new client or application setups, use 587 with STARTTLS or 465 with implicit TLS, and always authenticate. Port 25 is for servers talking to each other. Reasons for blocks and the choice between ports are explained in which SMTP port to use. Provider settings pages list their exact hostnames, and the SMTP settings guide explains each field.
A short SMTP conversation
SMTP commands are readable text, and the server replies with a three digit code. Below, C: is the client and S: the server.
S: 220 mail.example.org ESMTP
C: EHLO client.example.com
S: 250-mail.example.org
S: 250-STARTTLS
S: 250 SIZE 52428800
C: MAIL FROM:<[email protected]>
S: 250 OK
C: RCPT TO:<[email protected]>
S: 250 OK
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
C: Subject: Hello
C:
C: Hi Alice.
C: .
S: 250 Queued
C: QUIT
S: 221 ByeReplies beginning with 2 mean success, 4 means try again later, and 5 means permanent failure. Each command is explained in SMTP commands, and the codes in SMTP response codes.
SMTP versus IMAP and POP3
| Protocol | Direction | What it does | Typical ports |
|---|---|---|---|
| SMTP | Outgoing and between servers | Sends and relays messages | 25, 587, 465 |
| IMAP | Incoming to the client | Reads mail while it stays on the server, synchronised across devices | 143, 993 |
| POP3 | Incoming to the client | Downloads mail to one device, often removing it from the server | 110, 995 |
A mail account therefore needs both an outgoing SMTP server and an incoming IMAP or POP3 server, which is why settings screens ask for both. Compare them in IMAP, POP3 and SMTP compared.
Key terms you will meet
| Term | Meaning |
|---|---|
| MUA (mail user agent) | The mail client or application that composes and reads messages |
| MSA (mail submission agent) | The server that accepts new mail from clients, normally on port 587 or 465, after authentication |
| MTA (mail transfer agent) | The server that relays mail between domains over SMTP |
| MDA (mail delivery agent) | The component that places accepted mail into a mailbox |
| Envelope sender | The address given in MAIL FROM, where bounces go. See envelope from |
| Relay | A server that accepts mail and forwards it onward to another server |
In small setups one program may play several of these roles. In large ones they are separate systems, and a hosted sending service takes over the submission and transfer roles for you. The distinction matters when you debug, because a failure at submission (wrong password, blocked port) is a different problem from a failure at transfer (the destination refused the message).
Security and authentication
Plain SMTP has no encryption and, originally, no sender verification, which is why spam and forged mail are easy. Two layers fix this. Transport security uses TLS, either STARTTLS on port 587 or implicit TLS on 465, and protects the connection. Sender authentication uses SPF, DKIM and DMARC, which let receiving servers check that a message really comes from the domain it claims. SMTP authentication (AUTH) restricts who may submit mail to a server, so that it is not an open relay. Read TLS for email, email authentication explained and open relays.
SMTP in applications and services
Applications such as websites, shops and CRMs send mail through SMTP by connecting to a server with a hostname, port, username and password. Many providers also offer an HTTP API that does the same job without a long lived connection. Which to choose depends on your stack, and the trade-offs are in SMTP versus API. If you operate your own server, you take on reputation, authentication and queue management. See SMTP servers versus SMTP services.
Why SMTP is still built the way it is
SMTP was first specified in the early 1980s, when networks were small and trusted. It was designed to be simple to implement and to tolerate unreliable links, which is why it uses readable commands, queues messages and retries failed deliveries. Those same choices explain its weaknesses: the original protocol did not verify who a sender was and did not encrypt anything. Rather than replace SMTP, the industry added extensions that servers advertise in the EHLO reply, such as STARTTLS, AUTH, SIZE and 8BITMIME. Because of that, two servers that share no special configuration can still exchange mail using the common core, and each side uses the extras it supports. See SMTP extensions and the history of email.
Common problems
| Problem | Likely cause | What to check |
|---|---|---|
| Connection timed out | Port blocked by a firewall or provider | Try 587 or 465; see timeout and refused errors |
| Authentication failed (535) | Wrong username, password or app password | Re-enter credentials exactly |
| Must issue STARTTLS first (530) | Client not using encryption | Choose STARTTLS or SSL/TLS in the client |
| Message delivered to spam | Missing SPF, DKIM or DMARC, or poor reputation | Run the SPF, DKIM and DMARC checker |
| Bounce 550 user unknown | The recipient address does not exist | Correct or remove the address |
When to use SMTP and next steps
Use SMTP whenever a mail client, application or device needs to send email, since every mail system understands it. To go deeper, learn what each command does, test a server from the command line with telnet, openssl and swaks, and read how a relay differs from a plain server in SMTP relay explained.
Send over SMTP without running a server Use smtp.migosmtp.com on port 587 or 465 with authentication and get delivery, bounce and complaint events.
References and further reading
Frequently asked questions
What does SMTP stand for?
SMTP stands for Simple Mail Transfer Protocol, the standard for sending email between mail clients and servers.
What ports does SMTP use?
Port 25 for server to server delivery, 587 for client submission with STARTTLS and 465 for client submission over implicit TLS.
Is SMTP used to receive email?
Receiving servers use SMTP to accept mail from other servers, but you read mail from your mailbox with IMAP or POP3.
What is an SMTP server?
It is a server that accepts email by SMTP and either delivers it to local mailboxes or passes it on toward the recipient domain.
Is SMTP secure?
The base protocol is not. Security comes from TLS for the connection, authentication for senders and SPF, DKIM and DMARC for message authenticity.