---
title: "Test SMTP With Telnet: Ports 25, 587 and 465 | SendHQ"
description: Test SMTP with telnet on port 25 by typing EHLO, MAIL FROM, RCPT TO and DATA. For 587 and 465, use openssl s_client or swaks with AUTH.
canonical: https://sendhq.cc/blog/test-smtp-with-telnet
last-updated: 2026-11-21
author: Dhrumil Barot
author_bio: Dhrumil is an email marketing expert. Dhrumil built SendHQ so developers and AI agents can send, receive and track email without fighting deliverability on their own.
published: 2026-11-21
updated: 2026-11-21
---
# How to Test SMTP With Telnet (and What to Use on 587 and 465)

By [Dhrumil Barot](https://sendhq.cc/about.md#founder), Founder

Test SMTP with telnet on port 25 by typing EHLO, MAIL FROM, RCPT TO and DATA. For 587 and 465, use openssl s_client or swaks with AUTH.

Published November 21, 2026 · Updated November 21, 2026

**TL;DR:** To test SMTP with telnet, run `telnet mail.example.com 25`, wait for the `220` banner, then type `EHLO`, `MAIL FROM`, `RCPT TO`, `DATA`, your message, a line with a single `.`, and `QUIT`. Telnet only works on plain-text port 25; for port 587 (STARTTLS) or 465 (implicit TLS) use `openssl s_client` or `swaks`. If you send through an HTTP email API such as SendHQ, you test with an API call and read delivery events instead of an SMTP session.

> Building product or agent email and tired of guessing what happened to a message? [Create a SendHQ workspace](https://sendhq.cc/index.md) and see each send's delivery, bounce or complaint event.

A telnet SMTP test opens a raw TCP connection to a mail server and lets you type the same commands a mail server would send, reading each numeric reply as it comes back. A `220` banner proves the port is reachable, `250` replies to `EHLO` list what the server supports, and `250` after the final `.` proves the server accepted the message. Accepted is not delivered, so a full test ends with checking the recipient mailbox or the provider's event log. Microsoft's Exchange documentation uses exactly this method to test inbound and outbound mail flow ([Microsoft Learn](https://learn.microsoft.com/en-us/exchange/mail-flow/test-smtp-with-telnet)).

## What you need before you start

- A telnet client. Windows: `dism /online /Enable-Feature /FeatureName:TelnetClient` (admin prompt) or `Enable-WindowsOptionalFeature -Online -FeatureName TelnetClient` in PowerShell. macOS: `brew install telnet`. Debian or Ubuntu: `sudo apt install telnet`; Fedora or RHEL: `sudo dnf install telnet`.
- `openssl` for any TLS port (installed on almost every Linux and macOS system).
- The hostname of the SMTP server you want to test, and a recipient address you own.
- A network that allows outbound port 25. Many ISPs and cloud providers block it; Google Cloud, for example, blocks egress to port 25 ([Google Cloud firewall docs](https://cloud.google.com/vpc/docs/firewalls#blockedtraffic)).

## How do I test SMTP with telnet?

Follow these steps for a plain SMTP test on port 25.

1. Find the mail server for the recipient domain with an MX lookup:

```
   nslookup -type=mx example.com.
   # or
   dig +short MX example.com
```

The trailing period stops your resolver adding a local DNS suffix.

1. Connect on port 25 and wait for the banner:

`telnet mx1.example.com 25`

`220 mx1.example.com ESMTP ready`

1. Introduce yourself and read the extensions the server offers:

```
   EHLO test.yourdomain.com
   250-mx1.example.com Hello
   250-SIZE 52428800
   250-STARTTLS
   250 8BITMIME
```

1. Give the envelope sender and recipient:

```
   MAIL FROM:<you@yourdomain.com>
   250 2.1.0 Ok
   RCPT TO:<you@example.com>
   250 2.1.5 Ok
```

1. Send the message. `354` means the server is waiting for content; leave a blank line between headers and body, and end with a line holding only a period ([RFC 5321](https://www.rfc-editor.org/rfc/rfc5321)):

```
   DATA
   354 End data with <CR><LF>.<CR><LF>
   From: you@yourdomain.com
   To: you@example.com
   Subject: telnet test

   This is a telnet SMTP test.
   .
   250 2.0.0 Ok: queued as 4F2A1C
```

1. Close the session:

```
   QUIT
   221 2.0.0 Bye
```

1. Verify: check the recipient mailbox (including spam) and the full headers for SPF, DKIM and DMARC results.

Type carefully: backspace does not work once the session is open, and a typo returns an error such as `500 5.3.3 Unrecognized command` ([Microsoft Learn](https://learn.microsoft.com/en-us/exchange/mail-flow/test-smtp-with-telnet)). Our [SMTP commands reference](https://sendhq.cc/blog/smtp-commands) lists every command and its replies.

![A telnet SMTP session moves from banner to EHLO, envelope, DATA and a 250 queued reply](https://cdn.sanity.io/images/l4lj7ros/production/31328bf739a9e3c6ef19e5a79892c884e06a8bcf-1344x326.png?w=1280&auto=format)

Each step must return the code shown before you type the next command.

## Why can't I use telnet on port 587 or 465?

Telnet sends plain text and cannot do TLS. Port 587 is the message submission port; it expects you to upgrade with `STARTTLS` before you authenticate ([RFC 6409](https://www.rfc-editor.org/rfc/rfc6409)). Port 465 is implicit TLS: the TLS handshake starts the moment you connect ([RFC 8314](https://www.rfc-editor.org/rfc/rfc8314)). Telnet to 587 gets you a banner and an `EHLO` answer, but most servers refuse `AUTH` until TLS is on. Telnet to 465 shows nothing readable, because the server is waiting for a TLS ClientHello. Our guide to [ports 587 vs 465 vs 25](https://sendhq.cc/blog/smtp-port-587-vs-465-vs-25) covers which one to use.

| Port | Mode | Test tool | Command |
| --- | --- | --- | --- |
| 25 | Plain, optional STARTTLS | telnet | `telnet host 25` |
| 587 | STARTTLS then AUTH | openssl or swaks | `openssl s_client -starttls smtp -connect host:587 -crlf` |
| 465 | Implicit TLS then AUTH | openssl or swaks | `openssl s_client -connect host:465 -crlf` |
| 2525 | Provider fallback, usually STARTTLS | openssl | `openssl s_client -starttls smtp -connect host:2525 -crlf` |

## How to test port 587 with openssl s_client

`openssl s_client` does the TLS part and then gives you the same typing session as telnet ([OpenSSL docs](https://docs.openssl.org/3.0/man1/openssl-s_client/)).

1. Connect with STARTTLS:

`openssl s_client -starttls smtp -connect smtp.example.com:587 -crlf -quiet`

`-crlf` turns your line endings into CRLF, which SMTP requires. `-quiet` also stops s_client treating a line that starts with `R` or `Q` as a renegotiate or quit command, so `RCPT TO` works.

1. Send `EHLO test.yourdomain.com` again (the session restarts after TLS) and look for `250-AUTH PLAIN LOGIN`.
2. Authenticate (next section), then run `MAIL FROM`, `RCPT TO` and `DATA` exactly as on port 25.
3. For port 465, drop `-starttls smtp`: `openssl s_client -connect smtp.example.com:465 -crlf -quiet`.

## How do I test SMTP authentication from the command line?

Use `AUTH LOGIN` or `AUTH PLAIN` with base64-encoded credentials ([RFC 4954](https://www.rfc-editor.org/rfc/rfc4954), [RFC 4616](https://www.rfc-editor.org/rfc/rfc4616)). Encode them first:

```
printf '%s' 'you@yourdomain.com' | base64      # username for AUTH LOGIN
printf '%s' 'app-password' | base64            # password for AUTH LOGIN
printf '\0%s\0%s' 'you@yourdomain.com' 'app-password' | base64   # one string for AUTH PLAIN
```

```
AUTH LOGIN
334 VXNlcm5hbWU6
eW91QHlvdXJkb21haW4uY29t
334 UGFzc3dvcmQ6
YXBwLXBhc3N3b3Jk
235 2.7.0 Authentication successful
```

`334 VXNlcm5hbWU6` is base64 for "Username:", and `334 UGFzc3dvcmQ6` is "Password:". `235` means you are in; `535 5.7.8` means the credentials were rejected. Base64 is encoding, not encryption, so only do this inside TLS and use a throwaway or app password. Our [SMTP authentication](https://sendhq.cc/terms/smtp-authentication) page explains each mechanism.

![AUTH LOGIN prompts decode to Username and Password and a 235 reply confirms login](https://cdn.sanity.io/images/l4lj7ros/production/a0df4ad44581e9e3ff1160a77309a78cb8837fbb-1344x456.png?w=1280&auto=format)

Reply with your own base64 username and password after each 334.

## How do I send a test email from the Linux command line?

Swaks does the whole conversation in one command and prints every line, so it is the fastest repeatable test ([Swaks docs](https://github.com/jetmore/swaks/blob/develop/doc/base.pod)):

```
swaks --to you@example.com --from you@yourdomain.com \
  --server smtp.example.com --port 587 --tls \
  --auth LOGIN --auth-user you@yourdomain.com --auth-password 'app-password'
```

Use `--tls-on-connect` instead of `--tls` for port 465, and `--quit-after AUTH` to test the login without sending anything. For a comparison with Mailpit, smtp4dev and hosted checkers, see our [SMTP testing tools](https://sendhq.cc/blog/smtp-testing-tools) roundup.

## Testing an email API instead of SMTP: SendHQ

If your product or AI agent sends through an HTTP email API, there is no SMTP session to type. SendHQ is an email API with a REST interface, an MCP server for agents and a CLI. The test is one authenticated API request from a verified domain, then reading that message's events. Until a plan is active, a new SendHQ workspace runs a controlled integration trial: it delivers only to the account's own email or a mailbox-simulator address such as `success@simulator.amazonses.com`, so a test cannot reach a customer by mistake ([SendHQ quickstart](https://sendhq.cc/docs/quickstart.md)). Accepted is not delivered in SendHQ either: each send shows its delivery, bounce or complaint event, which is the step a telnet test leaves to you.

SendHQ does not replace telnet for diagnosing your own mail server or a recipient's MX; use the steps above for that.

## Common errors and what they mean

| What you see | Cause | Fix |
| --- | --- | --- |
| `Could not open connection to the host, on port 25: Connect failed` or a timeout | Port 25 blocked by ISP, cloud or firewall, or wrong host | Test from another network, use 587, check the MX host |
| Blank screen on 465 | Implicit TLS, telnet cannot speak it | `openssl s_client -connect host:465` |
| `530 5.7.0 Must issue a STARTTLS command first` | AUTH or MAIL before TLS on 587 | Use `openssl s_client -starttls smtp` |
| `535 5.7.8` | Wrong username, password or base64 | Re-encode with `printf '%s'` (no trailing newline) |
| `550 5.7.1 Relaying denied` | Sending to an outside domain without AUTH | Authenticate, or test with a local recipient |
| `500 5.3.3 Unrecognized command` | Typo or backspace in telnet | Retype the line cleanly |

Our [SMTP error codes](https://sendhq.cc/blog/smtp-errors) guide covers every reply code.

## What does it mean if telnet to port 25 times out?

A timeout means no TCP connection was made: something between you and the server dropped the packets. Most often your ISP or cloud provider blocks outbound port 25 to stop spam from compromised machines. Less often the host is wrong or the server's firewall only accepts known IPs. A `Connection refused` reply is different: it reached a host with nothing listening on that port.

## FAQ

### How do I test SMTP with telnet on Windows?

Enable the Telnet Client with `dism /online /Enable-Feature /FeatureName:TelnetClient`, then run `telnet mail.example.com 25` in Command Prompt and type the commands in the steps above. Microsoft also offers the Remote Connectivity Analyzer at testconnectivity.microsoft.com for an Inbound SMTP Email test.

### Can I test STARTTLS with telnet?

You can see `250-STARTTLS` in the `EHLO` reply and send `STARTTLS` to get `220 Ready to start TLS`, but telnet cannot complete the handshake. Use `openssl s_client -starttls smtp`.

### Does a 250 after DATA mean the email was delivered?

No. It means that server accepted the message for delivery. It can still bounce later or land in spam, so check the mailbox or your provider's event log.

### Is telnet safe for SMTP testing?

On port 25 without AUTH, yes: nothing secret is sent. Never type a real password over plain telnet; base64 is readable by anyone on the path.

### What is the difference between telnet and swaks for SMTP?

Telnet is a raw TCP client with no TLS or SMTP knowledge. Swaks speaks SMTP, handles STARTTLS, implicit TLS and AUTH, and runs the full test in one command.

Want each test message to come back with a clear delivery, bounce or complaint state? [Start a SendHQ workspace](https://sendhq.cc/index.md) and send your first email from a verified domain.

## Related articles

[SMTP Port 587 vs 465 vs 25: Which Should Your App Use?](https://sendhq.cc/blog/smtp-port-587-vs-465-vs-25) [10 Best SMTP Testing Tools (Compared by What They Prove)](https://sendhq.cc/blog/smtp-testing-tools) [SMTP Commands Reference: EHLO to QUIT, With Reply Codes](https://sendhq.cc/blog/smtp-commands) [SMTP SSL vs TLS: Which to Pick, STARTTLS or Implicit TLS](https://sendhq.cc/blog/smtp-ssl-vs-tls) [Bounce vs Complaint: What Actually Hurts Deliverability](https://sendhq.cc/blog/bounce-vs-complaint-deliverability)
