All articlesBest Practices

Best SMTP Settings for Reliable Email Delivery in 2025

The exact ports, encryption modes, authentication, and timeouts to use for production SMTP — plus a copy-paste config for the top providers.

The SMTPTester Team October 4, 2025 15 min read

A short answer first

For almost every production workload in 2025 you want port 587 with STARTTLS and AUTH LOGIN over an encrypted channel, or port 465 with implicit TLS if your library supports it cleanly. Port 25 is reserved for server-to-server relay and is widely blocked for outbound use.

That single line will solve 80 percent of "my email is not sending" tickets. The rest of this guide explains the why and the edge cases.

Picking the right port

PortEncryptionUse case
25OptionalMTA-to-MTA relay only
465Implicit TLSSubmission, broadly supported again
587STARTTLSModern submission, the default for most
2525STARTTLSFallback when 587/465 are firewall-blocked

Cloud platforms like AWS, GCP, and many residential ISPs block outbound port 25. If your application runs in a VPC and SMTP suddenly stops working after a migration, the firewall is usually the cause.

A quick way to tell a firewall block from a server problem: a firewall drop hangs until your timeout expires, while a server refusal returns a reply string almost immediately. If SMTPTester reports "connection timed out" rather than a numeric code, stop debugging credentials and go look at your egress rules.

Encryption: STARTTLS vs implicit TLS

Both deliver the same protection when correctly configured. The historical argument against STARTTLS was that a man-in-the-middle could strip the upgrade, but every serious client now enforces *require TLS* and aborts the session if the upgrade fails.

Use STARTTLS (587) when:

  • Your client library defaults to it.
  • You want to interoperate with the widest set of servers.

Use implicit TLS (465) when:

  • You want the cleanest cryptographic story (encrypted from byte one).
  • You are connecting to a provider that documents 465 as preferred (Zoho, FastMail, some Postfix builds).

Whichever you choose, insist on TLS 1.2 as a floor and prefer TLS 1.3. Disable SSLv3 and TLS 1.0/1.1 entirely — they fail modern compliance audits and provide no interoperability benefit in 2025.

Certificate validation is not optional

The most common self-inflicted security hole in email code is rejectUnauthorized: false (or its equivalent in Python, PHP, and Java). It disables hostname and chain verification, turning an encrypted channel into one any network operator can silently intercept.

If certificate validation fails, the correct fixes are:

  • Update the CA bundle on the machine.
  • Connect using the hostname the certificate was issued for, not an IP address.
  • Renew an expired certificate on a self-hosted server.

None of those are "turn verification off".

Authentication mechanism

Prefer AUTH LOGIN or AUTH PLAIN over an encrypted channel for password-based credentials. For OAuth-protected mailboxes (Gmail Workspace, Microsoft 365 with modern auth), use XOAUTH2 and refresh the token before each batch.

Never enable AUTH CRAM-MD5 as a primary mechanism — it predates modern TLS and forces the server to store passwords in a recoverable form.

Credential hygiene matters as much as mechanism choice:

  • One credential per application, never a shared "mail user".
  • Store secrets in a secret manager, not in environment files committed to git.
  • Rotate on a schedule and make rotation a non-event by deploying credentials dynamically.
  • Alert on authentication failures — a sudden spike usually means a rotation broke a service.

Connection pooling and timeouts

Real-world SMTP problems usually surface under load, not in tests. Production defaults to use:

  • Connection timeout: 10 seconds. SMTP handshakes that take longer almost always indicate a network issue.
  • Socket timeout: 30 seconds. Long enough to send a large message body.
  • Pool size: 5–10 concurrent connections per worker. Most providers throttle aggressively above this.
  • Keep-alive: Reuse sockets for batches. Reopening a TLS session for every recipient adds 200–400 ms of needless latency.
  • Max messages per connection: 100. Some providers close the socket silently after a threshold; recycle before they do.

Add jittered exponential backoff for 4xx replies: 1s, 2s, 4s, 8s, up to a cap of about five minutes. Retrying instantly and in lockstep across workers creates a thundering herd that providers interpret as abuse.

Sender identity: SPF, DKIM, DMARC

The SMTP layer accepts your connection. The deliverability layer decides whether the message reaches the inbox. Three records are non-negotiable in 2025:

  1. SPF — authorise your sending IPs.
  2. DKIM — sign each message with a 2048-bit key published in DNS.
  3. DMARC — publish a policy (start with p=none, monitor reports, then move to p=quarantine or p=reject).

Gmail and Yahoo now reject high-volume mail that fails DMARC alignment. There is no workaround.

Two additional records are quickly becoming expected: MTA-STS, which tells receiving servers to require TLS for your domain, and TLS-RPT, which delivers reports when a TLS connection to your domain fails. Neither affects inbox placement directly, but both signal an operationally mature sender.

Message construction defaults

Settings are not only about transport. These message-level defaults prevent a large share of spam-folder placement:

  • Always send a plain-text alternative alongside HTML.
  • Keep the total message under 100 KB before attachments; heavy HTML triggers clipping in Gmail.
  • Set a valid Reply-To and a real, monitored From address — never noreply@ if you can avoid it.
  • Include List-Unsubscribe and List-Unsubscribe-Post headers on bulk mail; both Gmail and Yahoo now require one-click unsubscribe for bulk senders.
  • Use a consistent Message-ID domain that matches your sending domain.

Provider quick-reference

Gmail:        smtp.gmail.com:587 STARTTLS, app password
M365:         smtp.office365.com:587 STARTTLS, UPN
SendGrid:     smtp.sendgrid.net:587 STARTTLS, "apikey" + API key
Mailgun:      smtp.mailgun.org:587 STARTTLS, postmaster@domain
Amazon SES:   email-smtp.<region>.amazonaws.com:587 STARTTLS, SMTP credentials
Postmark:     smtp.postmarkapp.com:587 STARTTLS, server token as both user/pass
Zoho:         smtp.zoho.com:465 SSL, full email address
Brevo:        smtp-relay.brevo.com:587 STARTTLS, login + SMTP key
Fastmail:     smtp.fastmail.com:465 SSL, app password

Separate your traffic streams

One of the highest-return configuration decisions has nothing to do with ports. Send transactional mail (password resets, receipts, alerts) and marketing mail from different subdomains, ideally through different IP pools.

Transactional mail earns excellent engagement and reputation. Marketing mail inevitably attracts complaints. Mixing them means a bad campaign can push password-reset emails into spam — a support catastrophe. Using mail.yourdomain.com for transactional and news.yourdomain.com for marketing isolates the reputations cleanly.

Rate limits and warm-up

New IPs and new domains have no reputation, and mailbox providers treat unknown senders with suspicion. A sensible warm-up curve for a dedicated IP looks roughly like this:

DayVolume
1–250–100
3–5500
6–102,000
11–1510,000
16–2550,000
26+Full volume

Send to your most engaged recipients first. Engagement early in the warm-up teaches filters that your mail is wanted.

Monitoring you should have before launch

  • Bounce rate — keep hard bounces below 2 percent; above 5 percent providers start throttling.
  • Complaint rate — Gmail's stated threshold is 0.3 percent; treat 0.1 percent as your alarm line.
  • Authentication pass rate — SPF, DKIM, and DMARC alignment should be at 100 percent, not 98.
  • Queue age — a growing queue is the earliest indicator of throttling.
  • TLS negotiation failures — sudden failures usually mean an expired certificate somewhere.

Wire these into the same dashboard as your application metrics. Email problems are usually noticed by customers first because nobody is watching the numbers.

A production-ready checklist

Before you ship a change to mail configuration, confirm every line:

  1. Port 587 with STARTTLS required, or 465 with implicit TLS.
  2. Certificate verification enabled.
  3. TLS 1.2 minimum.
  4. Dedicated, scoped credentials from a secret manager.
  5. Connection pool with keep-alive and a message cap.
  6. Timeouts set explicitly rather than left to library defaults.
  7. Retries with jittered exponential backoff, 4xx only.
  8. SPF, DKIM, DMARC published and aligned.
  9. Bounce and complaint webhooks handled and suppression list enforced.
  10. Synthetic hourly check that authenticates and alerts on failure.

Test before you ship

Run every change through SMTPTester before deploying. A 30-second test that confirms the connection, TLS negotiation, and authentication will save hours of customer-support work later — and running it from the same network your application uses catches the firewall issues that a laptop test would hide.

IPv6, DNS and hostname details

Two infrastructure details cause failures that look like configuration problems.

IPv6. If your server has an IPv6 address and your provider's hostname has an AAAA record, connections will prefer IPv6. Many receiving networks apply stricter policies to IPv6 senders, and some require a matching reverse DNS record that you may not have configured. If mail works from one host and fails from another with otherwise identical settings, check whether one is connecting over IPv6.

EHLO hostname. Your client identifies itself in the EHLO command. Libraries default to the machine's hostname, which in a container is often something meaningless like a3f9c2e1b004. Set it explicitly to a fully qualified domain name you control. Some receiving servers reject an EHLO argument that is not a valid FQDN, and the resulting 550 gives no hint about the cause.

Choosing between a shared and a dedicated IP

This decision has more impact on deliverability than any timeout value.

Shared IP pools are the right default below roughly 100,000 messages per month. Your volume alone is too low to establish a reputation, and riding on a well-managed pool borrows the provider's established standing. The trade-off is that another sender's behaviour affects you, though reputable providers police their pools aggressively.

Dedicated IPs make sense above that threshold, or when you need complete control and predictability. You own the reputation entirely — good and bad. A dedicated IP with low or irregular volume performs *worse* than a shared pool, because inconsistent sending never builds a stable signal.

If you take a dedicated IP, take at least two and keep them in the same pool so a single-IP outage does not stop mail.

Queueing architecture

The settings above assume your application is not sending mail synchronously inside a web request. If it is, fix that first.

A sensible architecture puts a durable queue between the application and the SMTP transport:

Web request -> enqueue job -> worker -> SMTP transport -> provider

This gives you three things that no SMTP setting can provide: requests that do not block on network latency, retries that survive a process restart, and a natural place to enforce rate limits and suppression checks.

Make jobs idempotent by attaching a deduplication key, so a retried job cannot send the same receipt twice. Store the provider's message ID on the originating record when the send succeeds, so support tickets can be traced without guessing.

Configuration as code

Mail settings drift. Someone changes a port in a staging environment to work around a firewall, and six months later nobody remembers why production and staging differ.

Keep the whole configuration in version control: host, port, encryption mode, minimum TLS version, timeouts, pool size, and the name of the secret (never its value). Review changes like any other code change. Add an automated test that asserts the production configuration uses port 587 or 465, requires TLS, and has certificate verification enabled — a five-line test that permanently prevents the most dangerous misconfiguration.

Reviewing settings quarterly

Provider requirements change. Set a recurring reminder to check four things:

  1. Has your provider deprecated a port, hostname or mechanism?
  2. Are your TLS floors still current?
  3. Are all credentials younger than your rotation policy allows?
  4. Do bounce and complaint rates still sit inside healthy thresholds?

Fifteen minutes a quarter prevents the surprise that arrives as a deprecation notice you never read.

Test your SMTP server now

Apply what you just learned. Free, no signup, results in seconds.

Open the tool →

Continue reading