Skip to content
send.io
All posts

SMTP ports explained: 25, 465 and 587

SMTP ports explained: use port 587 with STARTTLS for email submission, port 465 for legacy implicit TLS, and avoid port 25. This guide maps each port to its correct use case, shows how to test connectivity from the command line, and walks through a working port 587 configuration.

On this page
TL;DR: Use port 587 with STARTTLS for application email submission. Port 465 with implicit Transport Layer Security (TLS) encrypts from the first byte, and it's the standards-preferred long-term direction rather than a legacy fallback. Port 25 belongs to server-to-server relay only, and Amazon Web Services (AWS), Google Cloud, and Azure block outbound connections on it by default. Port 2525 works as an alternative when 587 and 465 are blocked. Configure your app for 587, test connectivity with openssl s_client -starttls smtp, and if you're using send.io's Simple Mail Transfer Protocol (SMTP) relay, use port 587 with STARTTLS, the only port it offers, and sign in with a mailbox address and its password, or a full-access Application Programming Interface (API) key of the owning team.

Your application can't send email, and the error says "connection refused" on port 25. The fix is a port change, not a code change, because AWS, Google Cloud, and Azure block outbound port 25 by default to prevent spam from compromised cloud instances.

Port 587 is the default SMTP port for application email submission, and Request for Comments (RFC) 8314 also recognizes port 465 as a valid submission port. Port 465 serves clients that connect with implicit TLS, which RFC 8314 defines as encrypted from the first byte, while port 25 exists for mail servers talking to each other, not for your app. This guide maps each port to its correct use case, shows you how to test connectivity from the command line, and walks through a working port 587 configuration with send.io's SMTP relay.

Choosing a secure SMTP port for email delivery

The port you select determines which encryption handshake your client performs and whether your cloud provider will let the connection through.

Port

Security Protocol

RFC Standard

Cloud Provider Blocking Status

Best Use Case

25

Plaintext, optional STARTTLS

RFC 5321

Blocked by AWS, Google Cloud Platform (GCP), Azure for outbound

Server-to-server relay between mail transfer agents (MTAs)

587

STARTTLS (upgrade after connect)

RFC 6409

Not blocked like port 25, but some providers throttle or block it

Application email submission (default)

465

Implicit TLS (TLS from first byte)

RFC 8314

Not blocked like port 25 by the major cloud providers, but explicit firewall rules may be required, and some corporate networks and Internet service providers (ISPs) block it

Clients and security policies that prefer implicit TLS

2525

STARTTLS

Not assigned by Internet Assigned Numbers Authority (IANA)

Requires explicit firewall rule

Alternative when 587 and 465 are blocked

Choosing the right SMTP port

Your infrastructure scenario determines which port to reach for first.

Infrastructure Scenario

Recommended Port

Reason

AWS Elastic Compute Cloud (EC2) instance or Lambda

587 or 465

AWS blocks outbound port 25 on all elastic network interfaces by default

Local development environment

587

Most residential ISPs allow outbound 587

Legacy on-prem server (older Java, .NET Framework)

465

Some older mail clients can't perform the STARTTLS upgrade and need implicit TLS, so check your library's documentation for supported modes

Google Cloud Compute Engine

587 or 465

By default, GCP blocks egress to Transmission Control Protocol (TCP) destination port 25 of external Internet Protocol (IP) addresses, but it places no restriction on ports 465 or 587

Residential or corporate network

587

Most ISPs allow outbound 587, but some block 25 to prevent spam from compromised machines

The pattern is consistent: port 25 fails from cloud environments, 587 is the most widely reachable submission port (though some providers throttle or block it), and 465 works when 587 is blocked or when a client can't handle STARTTLS.

Port 587 for submission and STARTTLS

Port 587 is the submission port defined in RFC 6409, and it expects the server to authenticate users before accepting mail. The connection starts in plaintext, your client sends STARTTLS to upgrade to an encrypted channel, and then authentication and message transmission happen inside the TLS session.

Port 587 is the most common default among email providers, though support for other ports varies, so check your provider's documentation for the ports it accepts. send.io's SMTP relay offers only port 587 with STARTTLS, and the setup section below shows how to sign in with a send.io mailbox address and password. Check the send.io SMTP documentation for the current settings before you configure each environment.

Port 465 for implicit TLS submission

Port 465 uses implicit TLS: the TLS handshake begins immediately on connection, before any SMTP commands are exchanged. Port 465 was registered for SMTP over TLS in the 1990s and later dropped from that use, then RFC 8314 restored it in 2018 as the port for implicit TLS submission.

Use 465 when your client library can't perform the STARTTLS upgrade. Some older Java mail libraries and .NET Framework's System.Net.Mail (which only supports explicit TLS via STARTTLS, not implicit TLS) can't negotiate the upgrade, so they need implicit TLS. Embedded systems with minimal TLS stacks may also benefit from implicit TLS, since it skips the STARTTLS command negotiation, though many embedded TLS libraries support both modes. The practical difference is that 465 encrypts from the first byte, while 587 upgrades mid-stream.

Using port 25 for SMTP relay

Port 25 is for server-to-server relay between MTAs, and it's the original SMTP port defined in RFC 5321. Do not use port 25 for client submission. AWS, Google Cloud, and Azure block outbound port 25 by default on all instances to prevent compromised machines from sending spam directly to recipient mail servers. If you're running a mail server that receives inbound email, port 25 is where other MTAs will connect, but your application should never send through it.

SMTP relaying on port 25 happens between mail servers, not between a client application and a relay. The typical flow is that your app connects to your relay provider on a submission port such as 587, and the provider's mail servers then relay the message to the recipient's mail server on port 25. In that general model, your application talks only to the submission port, so a cloud provider's block on outbound port 25 does not affect it. send.io's SMTP relay accepts submissions only on port 587 with STARTTLS, so your application never connects to it on port 25 or 465.

Using port 2525 for SMTP redundancy

No RFC defines port 2525, and IANA has not assigned it for SMTP use. It exists as a de facto alternative when 587 and 465 are blocked, and some providers accept it as an alternative submission port.

Port 2525 usually runs explicit STARTTLS, the same encryption upgrade as port 587, and most providers that offer it require an encrypted connection, so check your relay's documentation for the exact behavior. send.io's relay offers only port 587 with STARTTLS, so ports 2525 and 465 aren't available there. If your network blocks 587, ask your provider to open it or send with the HTTP API on port 443.

How SMTP ports handle TLS encryption

The encryption mode is determined by the port, not by a separate configuration setting. Port 587 expects STARTTLS, port 465 expects implicit TLS, and port 25 supports plaintext with optional STARTTLS. Mismatching the encryption mode to the port causes handshake failures.

Port 587 and 465 encryption standards

Port 587 uses STARTTLS as defined in RFC 3207, and port 465 uses implicit TLS as defined in RFC 8314. STARTTLS allows the client to request an upgrade to TLS after connecting in plaintext. Implicit TLS means the connection is encrypted from the first byte.

Both modes support TLS 1.2 and TLS 1.3, though the available cipher suites differ between TLS versions. The difference is in the connection setup, not the encryption strength. RFC 8314 requires TLS for email client-to-server submission on both 465 and 587.

Implementing STARTTLS on port 587

Most SMTP client libraries handle STARTTLS automatically when you configure port 587. In Nodemailer, set secure: false and the library sends STARTTLS after the Extended Hello (EHLO) command. In Python's smtplib, call server.starttls() explicitly. In Ruby, set enable_starttls_auto: true.

secure: false in Nodemailer does not mean unencrypted. It means the connection starts plaintext and upgrades via STARTTLS. Setting secure: true forces implicit TLS, which is what port 465 expects. Mismatching these settings causes handshake failures.

To test STARTTLS manually, use OpenSSL:

openssl s_client -starttls smtp -connect smtp.send.io:587 -crlf -quiet

This connects to port 587, sends STARTTLS, performs the TLS handshake, and drops you into an encrypted SMTP session. You can then type EHLO example.com, AUTH LOGIN, and the rest of the SMTP commands manually.

The STARTTLS upgrade handshake process

The STARTTLS handshake on port 587 follows this sequence:

  1. Client connects to server on port 587 in plaintext.
  2. Server responds with 220 Extended SMTP (ESMTP) greeting.
  3. Client sends EHLO, and the server responds with capabilities including STARTTLS.
  4. Client sends STARTTLS, and the server responds 220 Ready to start TLS.
  5. TLS handshake completes, establishing encrypted channel.
  6. Client sends EHLO again over TLS, authenticates, and sends message.

The initial EHLO and STARTTLS commands are unencrypted, which is why RFC 8314 requires TLS for email submission on both 465 and 587, deprecating cleartext authentication. After STARTTLS completes, the entire session is encrypted.

Implicit TLS port 465 handshakes

Implicit TLS on port 465 skips the STARTTLS command. The client connects, immediately sends a TLS ClientHello, and the server responds with a ServerHello and certificate. The TLS handshake completes before any SMTP commands are exchanged.

To test implicit TLS manually against a provider that offers port 465, use OpenSSL without the -starttls flag. send.io's SMTP relay doesn't offer port 465, so this example uses a placeholder host:

openssl s_client -connect smtp.example.com:465 -crlf -quiet

After the handshake completes, you can type SMTP commands directly. If the TLS handshake fails, the connection closes without any SMTP-level error message.

When to use port 587 vs 465

Use 587 as your default unless you have a specific reason to use 465. Port 587 is the standard defined in RFC 6409, it's supported by every major email library and provider, and AWS, GCP, and Azure don't block it the way they block port 25, though some environments need an explicit outbound firewall rule. RFC 8314 recommends implicit TLS in preference to STARTTLS over the long term, so port 465 isn't a legacy fallback, it's the standards-preferred direction. Port 587 remains the more common default today because of broader library and firewall-rule familiarity, not because 465 is outdated.

Use 465 when a client can't handle STARTTLS, when a firewall blocks 587, or when your security policy requires implicit TLS. The performance difference is negligible because the TLS handshake itself dominates the connection setup time.

Troubleshooting firewall blocks on port 587 and 465

Connection failures on SMTP ports fall into three categories: the port is blocked by a firewall, the encryption mode doesn't match the port, or authentication is failing after the connection succeeds.

Common SMTP port configuration errors

Symptom

Likely Cause

Fix

Connection refused on port 25

Cloud provider or ISP blocking outbound 25

Switch to port 587 or 465 for client submission

Timeout on port 587

Firewall blocking outbound 587, or wrong hostname

Test with nc -zv smtp.send.io 587, and if blocked, ask your host to open 587 or send with the HTTP API on port 443 (send.io offers only 587, so 465 and 2525 aren't options there)

TLS handshake failure on 465

Client configured for STARTTLS on implicit TLS port

Set secure: true in Nodemailer or use implicit TLS mode in your library

TLS handshake failure on 587

Client configured for implicit TLS on STARTTLS port

Set secure: false in Nodemailer or call starttls() explicitly

Authentication failure on 587

Wrong credentials, or credentials sent before STARTTLS

Use the full mailbox address as the username and the mailbox's current password as the password, and confirm STARTTLS completed before AUTH

Connection refused or timeout errors indicate a firewall blocking the SMTP port. TLS mode mismatches cause handshake failures when using implicit TLS settings on a STARTTLS port or vice versa. Using the wrong protocol for the port, such as STARTTLS against 465, causes handshake failures or timeouts.

Diagnosing SMTP port blocking

Test connectivity with nc (netcat) before debugging your application code:

nc -zv smtp.send.io 587

If the port is open, you'll see Connection to smtp.send.io port 587 [tcp/submission] succeeded!. If it's blocked, you'll see a timeout or connection refused error.

On Windows, use PowerShell:

Test-NetConnection -ComputerName smtp.send.io -Port 587

This tests TCP connectivity without requiring any SMTP knowledge. If the connection fails, the problem is network-level, not application-level.

Use telnet to test plaintext connectivity on port 587 before testing TLS:

telnet smtp.send.io 587

If the connection succeeds, you'll see an SMTP greeting that starts with 220 smtp.send.io ESMTP. Type EHLO example.com and you should see the capability list, including 250-STARTTLS. If telnet connects but OpenSSL fails, the problem is TLS-specific, not network-level. Check your certificate validation settings and confirm that your client trusts the server's certificate chain.

Configuring SMTP relay on port 587

send.io's SMTP relay documentation lists port 587 with STARTTLS as the relay configuration, and every example in this section uses it. The host is smtp.send.io, the username is the full address of a send.io mailbox on a verified domain, and the password is that mailbox's password. Confirm these settings against the send.io SMTP documentation before you configure each environment.

Setting up STARTTLS on port 587

In Node.js with Nodemailer:

const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
host: 'smtp.send.io',
port: 587,
secure: false, // STARTTLS on 587
requireTLS: true,
auth: {
user: 'hello@yourdomain.com', // full mailbox address
pass: process.env.SENDIO_SMTP_PASSWORD // mailbox password
}
});

await transporter.sendMail({
from: 'hello@yourdomain.com',
to: 'user@example.com',
subject: 'Test email',
text: 'Testing port 587 with STARTTLS'
});

The secure: false setting tells Nodemailer to use STARTTLS, and requireTLS: true makes it fail instead of sending without encryption. The connection starts plaintext, upgrades to TLS after the STARTTLS command, and then authenticates and sends the message inside the encrypted session.

Configuring port 587 with send.io

SMTP signs in as a mailbox, so the username is always a full address on one of your verified domains. Open Mailboxes in the send.io dashboard and create one, such as hello@yourdomain.com, or call POST /mailboxes. The password is shown once, and if you lose it, choose New password on the mailbox or call POST /mailboxes/{id}/password, and the old one stops working at once. A full-access API key of the team that owns the mailbox also works as the password for any of that team's mailboxes. Prefer the mailbox password in apps, because it can only send from that mailbox's domain, and remember that revoking a key stops SMTP logins with it immediately. Check the send.io SMTP documentation for the current settings.

Before you can send through send.io's SMTP relay, you need to verify your sending domain. Verify that your domain's Sender Policy Framework (SPF), DomainKeys Identified Mail (DKIM), and Domain-based Message Authentication, Reporting, and Conformance (DMARC) records point to send.io's infrastructure. send.io's domain management shows which records are missing or misconfigured, and delivery runs on Amazon Simple Email Service (SES) infrastructure with bounce and spam-complaint addresses automatically suppressed.

Testing your port 587 setup

Test your domain and API key with curl before you test SMTP. A message sent over SMTP appears in Emails like an API send, with the same delivery events and webhooks:

curl -X POST https://api.send.io/emails \
-H "Authorization: Bearer $SENDIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "app@yourdomain.com",
"to": "user@example.com",
"subject": "Test email",
"text": "Testing a send.io API send"
}'

This sends a test email through send.io's API. If the API call succeeds, your API key and domain are configured correctly. SMTP signs in separately with a mailbox address and password, so test SMTP next.

To test SMTP specifically, use OpenSSL to connect to port 587 and perform the STARTTLS handshake manually:

openssl s_client -starttls smtp -connect smtp.send.io:587 -crlf -quiet

After the TLS handshake completes, type EHLO example.com and confirm the capability list includes AUTH PLAIN LOGIN, which send.io offers only after STARTTLS. Then type AUTH LOGIN and paste your base64-encoded mailbox address and mailbox password when prompted, using the format in the send.io SMTP documentation. If authentication succeeds, you'll see 235 Authentication successful.

SMTP carries a finished message, so some features are API only. Test addresses such as delivered@send.io are simulated for API sends only, so over SMTP a message to them is really sent and bounces. Test SMTP with an inbox you own. Scheduling, templates, tags, and metadata have no SMTP headers, your SMTP client's own retry handling applies instead of idempotency keys, and the envelope sender must be the mailbox you sign in with. Sending from a different address returns 553 5.7.1 Sender address rejected.

For teams that prefer to skip SMTP entirely, send.io's Representational State Transfer (REST) API sends over HTTPS on port 443, so there is no SMTP port to choose or unblock. Authentication happens via bearer token instead of SMTP AUTH, and the API supports features that SMTP can't carry, such as scheduling, templates, tags, metadata, and idempotency keys. This is the recommended approach for new integrations, and it's the most direct path for artificial intelligence (AI) agents using send.io's Model Context Protocol (MCP) server, though automation tools outside the MCP-compatible set can call the REST API directly with a send.io key as well.

Test send.io's SMTP relay on port 587 with the OpenSSL command above, then provision a scoped API key if you want to send over HTTPS on port 443 instead. An API send authenticates with a bearer token in the Authorization header, appears in Emails with its delivery events, and triggers the same webhooks as an SMTP send, with no STARTTLS negotiation or SMTP client settings to configure.

FAQs

What SMTP port should an application use?

Use port 587 with STARTTLS for application email submission. Port 587 is the standard defined in RFC 6409. AWS, GCP, and Azure don't block it the way they block port 25 (though some environments need an explicit outbound firewall rule), and every major email library supports it.

Why is port 25 blocked on AWS, GCP, and Azure?

Cloud providers block outbound port 25 to prevent compromised instances from sending spam directly to recipient mail servers. Port 25 is for server-to-server relay, not client submission, and blocking it reduces abuse without affecting legitimate application email.

What's the difference between port 587 and 465?

Port 587 starts plaintext and upgrades to TLS via STARTTLS. Port 465 encrypts from the first byte using implicit TLS.

Can port 2525 be used instead of 587?

Yes, port 2525 is a de facto alternative that some providers accept when 587 and 465 are blocked. It's not defined in any RFC, but it works as a fallback. Port 2525 usually runs explicit STARTTLS, the same upgrade as port 587, and most providers that offer it require an encrypted connection, so check your provider's documentation for the exact behavior.

How do you test SMTP port connectivity from the command line?

Use nc -zv smtp.example.com 587 to test TCP connectivity, or openssl s_client -starttls smtp -connect smtp.example.com:587 to test the full STARTTLS handshake. On Windows, use Test-NetConnection -ComputerName smtp.example.com -Port 587 in PowerShell.

Key terms glossary

STARTTLS: An SMTP extension defined in RFC 3207 that upgrades a plaintext connection to TLS mid-stream. Used on port 587 for email submission.

Implicit TLS: TLS encryption that begins immediately on connection, before any protocol commands are exchanged. Used on port 465 for email submission, and RFC 8314 recommends it in preference to STARTTLS.

MTA (Mail Transfer Agent): A mail server that relays messages between other mail servers on port 25. Examples include Postfix, Sendmail, and Exchange.

Submission port: The port where client applications hand messages to a relay for delivery. Port 587 is the standard submission port defined in RFC 6409.

Scoped API key: An API credential with a limited permission list that can't grant permissions it doesn't hold.

MX (Mail Exchange) record: A Domain Name System (DNS) record that specifies which mail servers accept email for a domain. Other MTAs use MX records to route inbound email to your server.