New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
SMTP and APIUpdated 4 Nov 2026

What is SMTP? Simple Mail Transfer Protocol explained with ports and examples

SMTP is the protocol that moves email between mail clients and servers. This guide explains how it works, which ports it uses, how a message travels from sender to inbox, and how it differs from IMAP and POP3.

JL
Written by Jonas Lindqvist
Security Engineer
Reviewed by Hannah Mitchell
  • Published13 Jul 2024
  • Read time7 min
  • Length1,326 words
Share this guide

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 it isThe protocol used to submit and transfer email between servers
Ports25 for server to server, 587 for submission with STARTTLS, 465 for submission with implicit TLS
DirectionSending only: IMAP and POP3 are used to read mail
SpecificationRFC 5321 for transfer, RFC 6409 for submission

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

  1. Compose. You write the message in a mail client, a website or an application, called the mail user agent.
  2. Submit. The client connects to your outgoing SMTP server, authenticates and hands over the message. This server is the mail submission agent.
  3. Look up. The sending server reads the recipient domain's MX records in DNS to find which server accepts its mail. See MX records.
  4. 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.
  5. Accept and store. The receiving server checks the message and passes it to a delivery agent that places it in the recipient's mailbox.
  6. 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

PortUsed forEncryption
25Server to server delivery between mail transfer agentsOpportunistic STARTTLS; many networks block outbound traffic on this port
587Message submission from clients and applications (RFC 6409)STARTTLS upgrade, authentication required
465Message submission over implicit TLS (RFC 8314)TLS from the first byte
2525Not an official port; some providers offer it as an alternative when 587 is blockedProvider 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 Bye

Replies 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

ProtocolDirectionWhat it doesTypical ports
SMTPOutgoing and between serversSends and relays messages25, 587, 465
IMAPIncoming to the clientReads mail while it stays on the server, synchronised across devices143, 993
POP3Incoming to the clientDownloads mail to one device, often removing it from the server110, 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

TermMeaning
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 senderThe address given in MAIL FROM, where bounces go. See envelope from
RelayA 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

ProblemLikely causeWhat to check
Connection timed outPort blocked by a firewall or providerTry 587 or 465; see timeout and refused errors
Authentication failed (535)Wrong username, password or app passwordRe-enter credentials exactly
Must issue STARTTLS first (530)Client not using encryptionChoose STARTTLS or SSL/TLS in the client
Message delivered to spamMissing SPF, DKIM or DMARC, or poor reputationRun the SPF, DKIM and DMARC checker
Bounce 550 user unknownThe recipient address does not existCorrect 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.

Explore the SMTP relay

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.

Topics#smtp#basics#ports#email protocols#rfc 5321
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales