SMTP (Simple Mail Transfer Protocol) is the internet standard for sending email. It defines how an email program hands a message to a mail server, how mail servers pass that message to each other, and how the receiving server reports success or failure. Every email you send, from a newsletter to a password reset, travels over SMTP on its way to the recipient's mail server. SMTP only sends: reading mail is handled by IMAP or POP3.

How does SMTP work?

SMTP is a "push" protocol that runs over TCP. When you click Send, this is what happens:

  1. Submission: your email client or application connects to its outgoing SMTP server (usually on port 587), logs in and hands over the message.
  2. DNS lookup: the sending server looks up the MX record of the recipient's domain in the DNS to find which server accepts mail for that domain.
  3. Relay: the sending server opens an SMTP connection to the receiving server (server to server, usually on port 25) and transfers the message, sometimes through one or more relays.
  4. Checks and delivery: the receiving server checks the sender's authentication (SPF, DKIM, DMARC), accepts or rejects the message with a status code, then stores it in the recipient's mailbox.
  5. Retrieval: the recipient reads the email with IMAP, POP3 or webmail. SMTP is no longer involved at this stage.

SMTP commands

An SMTP session is a short text conversation between client and server. The main commands are:

Command What it does
EHLO / HELO The client introduces itself and asks which extensions the server supports (see HELO and EHLO).
STARTTLS Upgrades the connection to an encrypted one (see STARTTLS).
AUTH Logs in with a username and password or token.
MAIL FROM Declares the envelope sender, the address that receives bounces.
RCPT TO Declares one recipient; repeated for each recipient.
DATA Sends the message itself: headers, then body, ending with a line containing a single dot.
QUIT Closes the session.

Which SMTP port should you use?

Port Use Encryption
25 Server-to-server relay. Often blocked by internet providers and cloud hosts for outgoing mail from users. Optional (STARTTLS)
587 Message submission from email clients and applications. The recommended default. STARTTLS
465 Message submission over implicit TLS (SMTPS). TLS from the first byte
2525 Unofficial alternative offered by many providers when 587 is blocked. Usually STARTTLS

For a detailed comparison, read SMTP port 465 vs port 587 or the FAQ which SMTP port to use.

SMTP response codes

The server answers each command with a three-digit code. The first digit tells you the outcome:

  • 2xx, success: 220 (server ready), 250 (request completed).
  • 3xx, waiting for more: 354 (start sending the message data).
  • 4xx, temporary failure: 421 (service not available), 450 or 452 (mailbox busy or full). The sender retries later; this is a soft bounce.
  • 5xx, permanent failure: 550 (mailbox unavailable), 554 (transaction failed). The message is not delivered; this is a hard bounce.

See common SMTP errors and how to fix them.

SMTP vs IMAP vs POP3

SMTP IMAP POP3
Role Sends email Reads email, kept on the server Downloads email to one device
Direction Push (outgoing) Pull (incoming) Pull (incoming)
Usual ports 25, 587, 465 143, 993 110, 995

More in the FAQ difference between SMTP, IMAP and POP3.

SMTP server vs SMTP relay

An SMTP server is any mail server that speaks SMTP. An SMTP relay is a service that accepts your messages and delivers them on your behalf. Most businesses do not run their own sending server: they connect their website, CRM or application to a managed SMTP relay, which takes care of authentication, IP reputation, sending speed and bounce handling.

Is SMTP secure?

The original protocol sent everything in plain text. Today a well-configured setup adds three layers: encryption of the connection with TLS (STARTTLS or port 465), login with SMTP AUTH so only authorized users can send, and domain authentication with SPF, DKIM and DMARC, which prove to the receiving server that you are allowed to send for your domain.

A short history of SMTP

SMTP was first defined in RFC 821 in 1982. Extensions such as EHLO, authentication and encryption were added in the 1990s under the name Extended SMTP (ESMTP), and the current specification is RFC 5321, published in 2008. Despite its age, it remains the only standard protocol for sending email between servers.

SMTP FAQ

What does SMTP stand for? Simple Mail Transfer Protocol.

Can SMTP receive email? Receiving servers use SMTP to accept incoming messages, but you read your mail with IMAP or POP3. See can SMTP receive emails?

Where do I find my SMTP server settings? In your email provider's or sending service's documentation: you need the server name, port, username and password. See where to find your SMTP server.

Do I need my own SMTP server to send bulk email? No. Running one means managing IP reputation, blocklists and bounces yourself. A managed relay or an email marketing platform handles that for you.

See also

IMAP · DNS · DKIM

Running your own sending stack on AWS? See our comparison of the best Amazon SES alternatives.

Mailpro and SMTP

A managed SMTP relay, ready to send

Mailpro gives you a production-grade SMTP relay with authentication, IP reputation, throttling and reporting built in. Plug it in and start delivering — no server to operate.

Start free with MailproExplore the SMTP relay

Previous Article

   

Next Article

You might also be interested in:

An SMTP relay is a service that forwards email from your application, website, or server to recipients through a provider's authenticated sending infrastructure, instead of your own mail server. It is how apps reliably send t...
SMTPS (SMTP Secure) is the practice of sending email over SMTP through a connection that is encrypted with TLS/SSL from the very start. Historically tied to port 465, SMTPS wraps the entire SMTP session in encryption — so t...