---
title: What is SMTP? How the Simple Mail Transfer Protocol works
canonical: https://telnyx.com/email-api/what-is-smtp
lastModified: 2026-11-23T21:46:02.289Z
---
# What is SMTP? How the Simple Mail Transfer Protocol works

[View as page](https://telnyx.com/email-api/what-is-smtp) · [Site index for agents: llms.txt](https://telnyx.com/llms.txt)

[Back to Email API](https://telnyx.com/email-api)

Last updated 23 Nov 2026

# What is SMTP? How the Simple Mail Transfer Protocol works

See how SMTP moves email between servers, which port to use, and what a 250 reply actually means.

By [Eli Mogul](https://telnyx.com/authors/eli-mogul)Content Writer & Editor

See how SMTP moves email between servers, which port to use, and what a 250 reply actually means.

### Takeaways

* SMTP handles the sending half of email. Reading mail is a separate job for IMAP or POP3.
* A 250 reply means the next server now owns the message, not that anyone has read it.
* Encryption and logins arrived later as extensions, so a client upgrading to TLS has to introduce itself twice.
* Each of SMTP's weak spots has a named fix, from implicit TLS to strict line endings.

## What is SMTP?

SMTP is the protocol mail servers use to pass email to each other, and the one your app or mail client uses to hand a message to its first server. If you've ever pasted an "SMTP server" address into a settings screen, this is the conversation that address starts.

It works a lot like a courier network. You drop a parcel at the counter, it moves depot to depot, and the last depot holds it in a locker until the recipient picks it up. SMTP handles every handoff up to the locker. Picking it up is someone else's job.

### What does SMTP stand for?

SMTP stands for Simple Mail Transfer Protocol, and each word earns its place. Simple: a small set of plain-text commands. Mail: what it carries. Transfer: moving messages between servers, not storing or displaying them. Protocol: the rules both sides agree to follow.

It was first specified in RFC 821 in August 1982, and the current version, [RFC 5321](https://www.rfc-editor.org/rfc/rfc5321), dates from October 2008.

It's still being maintained. As of November 2026, a revision that would replace RFC 5321 is approved and waiting in the RFC Editor queue. It updates the specification; it doesn't change how your mail moves.

### How an email moves from sender to inbox

Say a customer forgets their password and your app sends a reset link. To them, it lands in seconds. Behind that, four handoffs get it from your code to their screen:

1. Your app or mail client submits the message to a submission server, usually on port 587.
2. That server looks up the recipient domain's MX (mail exchanger) records in DNS. Those records name the servers that accept mail for the domain.
3. The sending server delivers the message to the recipient's mail server over SMTP on port 25.
4. The recipient opens it later with IMAP or POP3.

SMTP covers the first three steps. The last one belongs to a different set of protocols.

Diagram of email delivery

### SMTP sends, IMAP and POP3 retrieve

SMTP pushes mail toward a mailbox, but it can't read one. IMAP and POP3 pull mail out. IMAP keeps messages on the server and syncs them across your phone and laptop, while POP3 downloads them to one device.

An easy way to remember it: SMTP is outbound, IMAP and POP3 are inbound. That's why your mail app asks for two server settings, one incoming and one outgoing.

## How does SMTP work?

SMTP is a text conversation over TCP: the client sends a command, the server answers with a three-digit code, and the message moves only after both sides agree on who is sending it and to whom. Think of a quick call with a front desk: you say hello, give your name, say who the package is from and who it's for, hand it over, and hang up. An SMTP session follows the same script, and you can read every line of it, which makes it one of the friendlier protocols to debug.

### The SMTP conversation, from EHLO to QUIT

Here's the session Telnyx publishes for its SMTP relay, with the encryption step most examples leave out.

```
S: 220 smtp.telnyx.com ESMTP email_submission
C: EHLO client.example.com
S: 250-smtp.telnyx.com
S: 250-SIZE 25000000
S: 250-8BITMIME
S: 250-PIPELINING
S: 250-SMTPUTF8
S: 250 STARTTLS
C: STARTTLS
S: 220 OK
   (TLS handshake)
C: EHLO client.example.com
S: 250-smtp.telnyx.com
S: 250-SIZE 25000000
S: 250-8BITMIME
S: 250-PIPELINING
S: 250-SMTPUTF8
S: 250 AUTH PLAIN LOGIN
C: AUTH PLAIN <base64 of "\0apikey\0YOUR_API_KEY">
S: 235 2.7.0 Authentication successful
C: MAIL FROM:<[email protected]>
S: 250 sender Ok
C: RCPT TO:<[email protected]>
S: 250 recipient Ok
C: DATA
S: 354 enter mail, end with line containing only '.'
C: (headers and body, then a line containing only ".")
S: 250 2.0.0 Ok: queued as 0f8fad5b-d9cb-469f-a165-70867728950e
C: QUIT
S: 221 Bye
```

S is the server, C is the client. Source: Telnyx [SMTP protocol contract](https://developers.telnyx.com/docs/messaging/email/smtp-protocol-contract).

Here's what each step does:

1. The server greets the client with 220, meaning it's ready.
2. The client says EHLO and names itself. The server lists the extensions it supports, one per line.
3. The client sends STARTTLS, gets a 220, and both sides run a TLS handshake.
4. The client says EHLO again. This time the list includes AUTH.
5. The client logs in with AUTH and gets 235.
6. MAIL FROM names the sender and RCPT TO names the recipient. Each gets a 250.
7. DATA gets a 354, the server's go-ahead. The client sends headers and body, then a line holding a single period to mark the end.
8. The server answers 250 with a queue ID, and the client signs off with QUIT.

Step 4 is the one that trips people up. The TLS handshake resets the session to its starting state, so the client has to introduce itself again, and the server only offers AUTH in that second reply. If your login fails right after you turned on encryption, check that your client sends EHLO after STARTTLS.

One more detail: MAIL FROM and RCPT TO form the envelope, the addresses servers actually route on. They can differ from the From and To lines you see in your inbox, which is how BCC works.

### What a 250 reply means

Diagram of SMTP handoffs

A 250 after the message data is a handoff, not a delivery receipt. The standard says a server sending that reply is "accepting responsibility for delivering or relaying the message." Each hop stores the message, then forwards it.

It's like checking a bag on a connecting flight. Once the first airline tags it, you're free to walk to your gate, but the bag still has a transfer ahead of it. Each airline owns the bag until the next one takes it.

So when your app gets a 250, its part is done. The message might still be sitting in a queue two servers away. Telnyx's final reply, `250 2.0.0 Ok: queued as <uuid>`, carries the Telnyx message ID. A 250 means Telnyx accepted the message; delivery results arrive later as [events](https://developers.telnyx.com/docs/messaging/email/webhooks-events).

### When delivery fails: 4xx retries and 5xx bounces

SMTP sorts failures into two kinds. A 4xx reply is temporary: try again later. A 5xx reply is permanent: stop trying and send a bounce back to the sender.

The standard is patient with temporary failures. It recommends that a sending server wait at least 30 minutes between retries and keep trying for at least 4 to 5 days. That's a recommendation, not a guarantee, and plenty of providers give up sooner.

Picture a small company whose mail server goes down overnight. Mail you sent them at midnight doesn't vanish. Sending servers hold it in their queues, retry through the night, and deliver it when the server comes back in the morning. If an email ever showed up hours late with no explanation, this is usually why.

## SMTP vs ESMTP: the extensions in use today

ESMTP (Extended SMTP) is SMTP plus optional features, and nearly every server today speaks it. A client opens with EHLO instead of the original HELO, and the server replies with the list of extensions it supports.

### How EHLO tells a client what the server supports

Original SMTP carried 7-bit US-ASCII text only. That meant no raw binary, no accented characters in addresses, no encryption, and no logins.

Extensions added each of those without touching the base protocol. EHLO is the client asking "what can you do?" before it starts. The server lists its features, and the client uses only what it sees. No guesswork. On Telnyx's relay, a client that sends HELO instead of EHLO gets no extensions, so it can't start TLS or log in.

### SMTP extensions you will see in an EHLO reply

Look back at the transcript and you can read the extension list line by line:

* SIZE (RFC 1870) declares the largest message the server accepts.
* 8BITMIME (RFC 6152) allows 8-bit text in the message body.
* PIPELINING (RFC 2920) lets the client send several commands without waiting for each reply.
* SMTPUTF8 (RFC 6531) allows non-ASCII characters in addresses.
* STARTTLS (RFC 3207) upgrades the connection to TLS.
* AUTH (RFC 4954) lets the client log in.

Telnyx's relay lists STARTTLS only before encryption and AUTH only after it, which is the session reset from the previous section in action. Two extensions it doesn't advertise are CHUNKING (RFC 3030), which sends a message in sized pieces, and DSN (RFC 3461), which requests delivery status notifications. Telnyx's relay refuses DSN parameters such as NOTIFY and RET with a 555 reply.

Make your first inference call

Create an API key in the Mission Control Portal and point your code at Telnyx.

[Sign up](https://telnyx.com/sign-up)[Contact us](https://telnyx.com/contact-us)

## Is SMTP TCP or UDP? Ports and connections

SMTP runs over TCP, never UDP, because it needs every line of the conversation to arrive in order.

### SMTP runs over TCP, not UDP

The SMTP standard asks for only one thing from the network: a channel that delivers data reliably and in order. That's exactly what TCP provides. UDP promises neither, and no UDP port is even assigned for SMTP submission over TLS.

Imagine someone reading you a recipe over a bad phone line, and the steps arrive scrambled. You'd frost the cake before you baked it. SMTP has the same problem: if a line went missing or arrived early, a server could see DATA before it knew who the message was for.

### Which port SMTP uses: 25, 587, or 465

_The three registered SMTP ports and what each is for._

| Port    | Used for                              | Encryption                          |
| ------- | ------------------------------------- | ----------------------------------- |
| **25**  | Server-to-server delivery             | STARTTLS when both sides support it |
| **587** | Submission from apps and mail clients | STARTTLS                            |
| **465** | Submission from apps and mail clients | Implicit TLS                        |

If you're setting up an app, a plugin, or an office printer, you'll almost always want 587\. Port 25 causes the most headaches: some networks block outbound traffic on it, and cloud providers such as Amazon EC2 do so by default. That's why a scanner that can't email scans, or a script on a fresh VM that just times out, is often a port 25 problem. You may also see port 2525, which isn't a registered SMTP port, only a workaround some providers offer.

Telnyx's relay takes mail on port 587 with STARTTLS only; it does not offer implicit TLS on port 465.

## Is SMTP secure?

SMTP was designed without encryption or sender checks; everything that secures it today was added on top, and each layer covers a different gap. In 1982, sending an email was a lot like mailing a postcard: anyone who handled it along the way could read it, and nobody checked the return address. Knowing which layer fixes which problem tells you where to look when something goes wrong.

### STARTTLS vs implicit TLS

Diagram comparing STARTTLS

STARTTLS upgrades a plain connection to TLS (Transport Layer Security, the same encryption behind HTTPS) after EHLO. Implicit TLS, on port 465, is encrypted from the first byte.

The weak spot is those first few plain-text lines. [NIST's email security guidance](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-177r1.pdf) describes how an attacker in the path can strip the STARTTLS offer from the server's reply, leaving the session in cleartext. In a 2015 study presented at the ACM Internet Measurement Conference, all five popular mail servers tested fell back to cleartext when STARTTLS failed.

That's why RFC 8314, the current standard for mail submission, prefers implicit TLS. A relay can close part of the gap by refusing logins until encryption is up. If a client tries to log in before STARTTLS, Telnyx's relay refuses with `538 5.7.11 Encryption required` and keeps the connection open.

Receiving domains can go further by publishing an MTA-STS or DANE policy that tells senders to require TLS, as NIST recommends. Getting it right is another matter: a 2025 study found 29.6% of the roughly 68,000 domains with an MTA-STS record had it set up wrong.

### SMTP authentication

AUTH is the ID check at the counter: it lets a relay confirm who's sending before it accepts mail. Without it, a server becomes an open relay that forwards anyone's spam.

The common PLAIN method sends your password unencrypted, so it's only safe inside TLS. That's why AUTH belongs after STARTTLS. On Telnyx's relay, log in with AUTH PLAIN or AUTH LOGIN. The username is the literal word `apikey`, and the password is a Telnyx API v2 key.

### What TLS does not stop: spoofing and smuggling

TLS protects the connection, not the sender's identity. Think of it as a sealed envelope: nobody can read what's inside, but anyone can still write a fake return address on the front. Proving who sent it is the job of [SPF, DKIM, and DMARC](https://developers.telnyx.com/docs/messaging/email/domains).

SMTP smuggling exploits a different gap. Some servers disagree on where message data ends, so an attacker can hide a second, forged message inside the first one and get it relayed with a spoofed sender that passes SPF.

It was published in December 2023 as CVEs against Postfix, Sendmail, and Exim (CVE-2023-51764, CVE-2023-51765, and CVE-2023-51766). The fix is to refuse any line ending that isn't a full CRLF (carriage return plus line feed). Telnyx's relay can refuse message data with bare LF or bare CR line endings, replying `451 Bare newline detected`.

## Sending email over SMTP from an application

An app sends email over SMTP the same way a mail client does: it needs a host, a port, an encryption setting, and a username and password. If you control the code, compare [SMTP relay vs API](https://telnyx.com/email-api/what-is-an-email-api#email-api-vs-smtp-relay) before you commit to one.

### The settings an app needs to send over SMTP

Telnyx's SMTP relay accepts mail at smtp.telnyx.com on port 587 and requires STARTTLS before any login or message. If you've ever set up a contact form plugin or a mail library, these four settings will look familiar:

* Host: smtp.telnyx.com
* Port: 587
* Encryption: STARTTLS
* Username and password: `apikey` and a Telnyx API v2 key

The MAIL FROM address must use a verified sending domain on the account that owns the API key. Telnyx keeps the Message-ID your message carries and may add a DKIM signature, but it doesn't add a missing Message-ID or Date header, so set both on every message.

Telnyx publishes [SMTP setup guides](https://developers.telnyx.com/docs/messaging/email/smtp-migration-guides) for Nodemailer, Django, Rails, Laravel, WordPress, Spring, and Python's smtplib.

### What a relay checks before it accepts a message

Telnyx's SMTP relay caps each message at 25,000,000 bytes and each connection at 50 accepted recipients. It also closes a connection after 30 seconds idle and ends a session 5 minutes after login, so long-lived connection pools need to reconnect.

Two behaviors are worth building for. In rare cases, a `451 4.3.0` reply at the end of DATA still means Telnyx accepted the message, so a retry can deliver a duplicate. So if a customer tells you they got the same receipt twice, check your retry logic first.

The other is tracking. Mail sent over Telnyx's SMTP relay gets no open or click tracking. Use the Email API when you need it.

SMTP sends run through the same pipeline as [Telnyx Email API](https://telnyx.com/products/email-api) sends: the same verified domains, quotas, billing, and webhooks.

## Frequently asked questions about SMTP

Here are short answers to the SMTP questions that come up most.

**Do emails still use SMTP?**  
Yes, emails still use SMTP. Mail servers hand messages to each other over SMTP today, including mail an app first submitted through an HTTPS API: the provider behind that API still delivers it over SMTP. The standard is being reissued, not retired, with a revision approved and waiting for publication as of November 2026.

**What is used instead of SMTP?**  
Nothing replaces SMTP for server-to-server delivery. What changes is the first hop. Many apps hand mail to a provider by [sending through an API](https://telnyx.com/email-api/what-is-an-email-api) over HTTPS, and some mail clients talk to their server with JMAP. Behind both, the server still submits and delivers the message over SMTP.

**Is Gmail an SMTP server?**  
Gmail runs SMTP servers, though it's an email service rather than a single server. If you set up a mail client or device to send through a Gmail account, Google's outgoing server is smtp.gmail.com on port 587 with STARTTLS and your login. Our SMTP server guide covers settings for other popular providers. \[Link when the planned page is live.\]

**Is SMTP a layer 7 protocol?**  
Yes, SMTP is a layer 7 protocol. It sits at the application layer of the OSI model, alongside HTTP and IMAP, and runs over TCP at the transport layer below. SMTP defines the conversation: commands, replies, and where a message ends. TCP gets each line across the network intact and in order.

**Is SIP the same as SMTP?**  
No, SIP and SMTP do different jobs. SIP (Session Initiation Protocol) sets up voice and video calls, while SMTP moves email. The mix-up makes sense: SIP borrowed SMTP's style of text commands and numbered replies, and SIP addresses look like email addresses. In voice networks, SIP shows up most often in [SIP trunking](https://telnyx.com/products/sip-trunks).

---

Send email over SMTP or the API Create a Telnyx account, verify a sending domain, and point your app at [smtp.telnyx.com](http://smtp.telnyx.com) on port 587.

Eli Mogul

Content Writer & Editor

Eli is the content writer and editor at Telnyx. Born and raised in Chicago, Eli attended the University of Missouri where he obtained a BA in Journalism. Eli joined Telnyx in August of 2025\. In his spare time, you'll find Eli reading, playing video games, or running.

[Start building](https://telnyx.com/sign-up)
