EXAMTOPICS / TECHNOLOGY INSIGHTS

SMTP Ports 25, 465, and 587: Mail Delivery and Security

SMTP port configuration is easier to understand once you separate two jobs that happen during the same email journey. A message submission agent accepts mail from a user, application, or authenticated device. A message transfer agent relays that mail toward the recipient’s domain. The two jobs use related SMTP commands, but they are not interchangeable and should not inherit identical authentication or encryption rules.

Port 25 is principally for server-to-server transfer; port 587 is for message submission using STARTTLS; port 465 is for submission with TLS from the beginning of the connection. None of these numbers independently guarantees delivery or security. Your server’s role, the remote provider’s requirements, TLS enforcement, authentication method, and outbound-network policy determine the correct choice.

Port 25: receiving and relaying mail between servers

Suppose Alice sends a message from alice@example-a.com to bob@example-b.com. Her mail client submits the message to the service that handles outgoing mail for example-a.com. That service looks up the receiving domain’s DNS mail-exchanger (MX) records and opens a connection to the selected destination mail server. The standard SMTP transport for that server-to-server handoff uses TCP port 25.

That distinction is formalized in RFC 6409: mail relay remains on port 25, while message submission normally uses port 587. The distinction matters whenever someone asks an administrator to “change the SMTP port” without specifying whether the component is a user’s outgoing mail client, an application relay connector, or an internet-facing receiving server.

Port 25 is not synonymous with cleartext. Mail transfer agents can advertise the STARTTLS extension, negotiate TLS, and encrypt an SMTP transport session. However, an ordinary public MX receiving mail from arbitrary internet senders must remain interoperable with servers that cannot negotiate TLS; RFC 3207 addresses that public-server constraint. Organizations that require stronger protection on particular transport paths can use additional policies and mechanisms rather than assuming the port number alone enforces encryption.

An open relay is a different issue from an MX accepting mail addressed to its own users. An internet-facing MX must accept properly addressed mail for the domains it hosts, subject to antispam and security policy. It must not casually accept arbitrary third-party mail for onward delivery. Relay restrictions, trusted-network boundaries, authentication where appropriate, rate limits, and abuse monitoring prevent an internal transport function from becoming an unsolicited-mail distribution channel.

Some consumer ISPs and cloud hosting environments block outbound TCP/25 from customer networks to reduce spam from compromised systems. That block can prevent a self-hosted mail server from delivering directly to other domains even when inbound mail works. Confirm the provider’s rules before building a direct-delivery architecture; do not assume that changing the server to port 587 will allow server-to-server MX delivery, since the destination MX ordinarily listens on port 25.

Port 587: authenticated message submission with STARTTLS

Port 587 is the standard submission port for a mail client, application, or device sending a new message through a designated submission service. A submission agent can identify the sending user or service, enforce sender-address policies, reject malformed content, add local policy requirements, and queue messages for later relay. These are intentionally different responsibilities from accepting inbound mail from the open internet.

A typical connection to port 587 starts in ordinary SMTP and then uses the STARTTLS command to negotiate encryption before transmitting credentials or sensitive mail data. A secure implementation requires successful TLS negotiation rather than quietly sending credentials or message contents when TLS is unavailable. Successful STARTTLS is only meaningful if the client also validates the server’s certificate and connects to the intended submission host.

The submission service generally requires SMTP authentication, or another deliberately scoped authorization arrangement, before allowing a user or application to send mail. Some organizations authorize trusted devices or application connectors by identity or network controls rather than using a username/password pair for every message. The operational requirement is an explicit, accountable authorization policy—not a claim that every connection to TCP/587 universally presents a password prompt.

For example, a monitoring system running inside a private network may submit alerts through an organization’s designated authenticated gateway. A laptop roaming on untrusted networks should submit through the organization’s approved service with certificate validation and suitable credentials or modern authentication. Neither should be configured to relay arbitrary mail through a public MX merely because the client can reach port 25.

Port 465: submission with implicit TLS

Port 465 also has a legitimate modern role. With the submissions service, the client begins a TLS handshake immediately upon connecting; SMTP commands follow only after that protected channel is established. This is called implicit TLS, in contrast with explicit TLS using STARTTLS after an initial SMTP greeting on port 587.

RFC 8314 describes port 465 for implicit-TLS message submission and discusses deployment alongside STARTTLS on port 587. Correctly implemented port 587 with mandatory STARTTLS and port 465 with implicit TLS can both provide strong transport protection. Port 465 is not inherently “obsolete,” and port 587 is not inherently stronger merely because the number is higher.

Choose the port and security mode as a pair. If a provider publishes smtp.example.com:465 with SSL/TLS, configure the mail client for implicit TLS rather than attempting STARTTLS after a plaintext greeting. If the provider publishes smtp.example.com:587 with STARTTLS, configure mandatory STARTTLS and confirm authentication is supported. Trying the wrong TLS mode can produce connection resets, handshake failures, or apparently inexplicable client timeouts.

Port Typical role Initial connection Primary protection decision
25 Mail transfer between MTAs; receiving internet mail SMTP greeting; may negotiate STARTTLS Manage relay authorization, opportunistic or policy-governed TLS, DNS routing, and abuse controls
587 Client and application message submission SMTP greeting, followed by STARTTLS Require TLS when submitting sensitive mail and use an approved authorization method
465 Client and application submission TLS handshake before SMTP greeting Validate the certificate, enforce appropriate authorization, and use implicit TLS

These roles are common standards-based defaults, not proof of what a particular provider has enabled. A service may intentionally expose only one submission port, require OAuth or another provider-specific authorization mechanism, or restrict connections to certain source networks. Always use the receiving service’s published configuration.

How to choose the right port for your workload

A user sending from Outlook, Thunderbird, a mobile mail app, or a business application should use the service’s documented submission endpoint—usually 587 with mandatory STARTTLS or 465 with implicit TLS. The organization’s identity and device-management policies determine whether password-based SMTP authentication is permitted; some providers disable older basic-authentication mechanisms in favor of supported modern authentication.

A mail gateway delivering to the recipient domain’s MX normally uses port 25. Its responsibilities include queueing and retrying temporary failures, respecting DNS MX preferences, avoiding unauthorized relay, inspecting delivery responses, and applying the organization’s transport-security policy. Do not redirect MX delivery to port 587 unless a specific provider design calls for an authenticated smart host rather than direct MX relay.

A multifunction printer, scanner, or legacy application often needs a submission relay because it cannot meet the cloud provider’s current TLS or authentication requirements. A well-scoped internal gateway can accept mail only from approved device IPs or identities, log every submission, limit sender addresses and destinations, and relay through a supported authenticated upstream service. Exposing an unauthenticated relay to the public internet would solve the wrong problem and introduce substantial risk.

An organization operating its own mail infrastructure must consider outbound IP reputation, reverse DNS, SPF, DKIM, DMARC, abuse reports, queue visibility, transport TLS, patching, and policy-based access in addition to port selection. These tradeoffs are central when comparing on-premises mail servers with managed email platforms; control over the transport stack also creates ongoing operational responsibility.

Diagnosing failures without guessing at the port

A failed connection does not always mean the port is wrong. Troubleshoot in layers, starting with the direction and intended service. Is the machine trying to submit to a configured outgoing server, or is an MTA trying to deliver directly to an MX? Is it reaching the DNS name and address the provider documented? Does the network permit outbound traffic to that endpoint? A DNS or firewall problem may appear before SMTP has even begun.

For port 587, test that the server announces STARTTLS and that the client can negotiate TLS with a valid certificate. Then check the actual authorization error separately. SMTP responses such as 530 Authentication required or 535 Authentication credentials invalid point to submission policy or credentials rather than a general TCP port issue. A STARTTLS negotiation failure or certificate-name mismatch requires TLS configuration work, not a workaround that disables encryption.

For port 465, the TLS handshake must begin immediately. A client waiting for a plaintext 220 SMTP banner before starting TLS may hang because the server is waiting for the client’s TLS handshake. Confirm the server name, certificate chain, TLS versions, and application configuration before changing the account password.

For direct mail delivery on port 25, test DNS MX resolution and outbound TCP reachability from the actual sending environment. Then inspect queue entries and remote SMTP responses. A temporary 4xx response can require a retry; a permanent 5xx response should trigger investigation of policy, recipient validity, domain reputation, or message format. Repeatedly switching from 25 to 587 will not fix a public MX rejection.

Keep an eye on whether a reported “connection refused” happens at TCP setup, a TLS negotiation error happens after the connection, or a policy rejection arrives as a formal SMTP status code. Those are different failure categories with different owners. Log timestamps, destination host and port, the stage of failure, and the sanitized response code; never place plaintext passwords or authorization tokens in troubleshooting logs.

Security measures beyond the port number

SMTP transport encryption protects a connection between two endpoints but does not inherently provide end-to-end message confidentiality. A mail server may decrypt a message and transmit it over a different hop. Sensitive-data policies may therefore require message-level protection, controlled recipients, data-loss prevention, or organizationally mandated transport enforcement in addition to STARTTLS or implicit TLS.

SPF, DKIM, and DMARC address sender authorization, cryptographic message-domain attribution, and domain policy for authentication alignment; they do not choose the SMTP port or encrypt the transport connection. Likewise, a TLS handshake does not prove that the sender’s domain is authorized. Treat origin authentication, submission authorization, transport protection, recipient policy, and mailbox access as separate security controls.

A secure submission deployment should have clear certificate-validation requirements, a documented authentication method, strong credential or token management, abuse-rate limits, and meaningful logging. A secure MX deployment should reject unauthorized third-party relaying, maintain a reliable retry path, and monitor delivery anomalies. These controls have more influence on real-world outcomes than a statement that one port is “safe” and the other “unsafe.”

In practice, the configuration question should be phrased as “Who is sending, to which service, for which role, and with which enforced security settings?” That gives you a reliable answer: TCP/25 for ordinary server-to-server SMTP transfer, TCP/587 for properly secured STARTTLS submission, or TCP/465 for implicit-TLS submission when supported by the provider.