MailSlurp logo

guides

What Is SSL for Email? TLS, STARTTLS, and What Email Encryption Actually Protects

Understand SSL for email, how TLS and STARTTLS protect mail connections, which ports to use, and how to check certificates without sending a message.

Use with your tools
What Is SSL for Email? TLS, STARTTLS, and What Email Encryption Actually Protects article preview

"SSL for email" usually means an encrypted connection between your email client or application and a mail server. Modern systems use TLS, the successor to SSL, even when a settings screen still calls the option "SSL" or "SSL/TLS".

TLS protects traffic while it crosses that connection. It does not automatically encrypt the message end to end: a mail service can process and store the message after the connection ends, and each later transfer has its own security settings.

SSL, TLS, and STARTTLS in an email setting

SSL and TLS name generations of the security protocol. SSL is obsolete, and TLS 1.0 and 1.1 are also deprecated by the IETF. Use current mail software with TLS 1.2 or later rather than enabling an old protocol to make a connection succeed.

STARTTLS describes how a connection begins using TLS. An SMTP client first connects, asks what the server supports with EHLO, and then issues STARTTLS. After a successful TLS handshake, it asks for capabilities again before continuing with authentication or mail submission. The SMTP STARTTLS specification requires the pre-TLS session knowledge to be discarded.

The other common approach is implicit TLS: encryption is negotiated immediately when the connection opens. Neither label tells you whether certificate validation is enabled or whether an application will stop after a TLS failure. Those are essential configuration checks.

Common email ports and TLS expectations

Your outgoing server uses SMTP; incoming mailbox access usually uses IMAP or POP. Choose the provider's hostname, port, and encryption mode as a set.

Connection Port How TLS starts
SMTP submission 465 Immediately, before the SMTP greeting
SMTP submission 587 Through STARTTLS, before authentication and submission
IMAP mailbox access 993 Immediately
POP3 mailbox access 995 Immediately
SMTP server-to-server relay 25 STARTTLS where supported and required by the sending server's policy

RFC 8314 recommends implicit TLS for email submission and access, while also recognizing STARTTLS submission on 587. Correct implementations of either submission mode can provide equivalent security when successful TLS negotiation is required. That recommendation concerns client submission and mailbox access; server-to-server relay has separate policies.

For example, Gmail SMTP documents 465 for implicit TLS and 587 for STARTTLS. Selecting 465 while telling the client to wait for a plaintext greeting is a mismatch. So is attempting an immediate TLS handshake against a STARTTLS endpoint.

What email TLS actually protects

A properly verified TLS connection protects the confidentiality and integrity of data in transit between its two endpoints and authenticates the server to the client. The TLS specification describes these properties. For an app submitting email, the endpoints are the app and its submission server, not necessarily the eventual recipient.

Consider a message submitted to one provider and then relayed to a recipient's provider. TLS on the first connection protects that first transfer. The second connection needs its own TLS negotiation and policy, and each provider can still process the message at its endpoint.

End-to-end message encryption protects the message content for the intended recipients beyond any one network connection. TLS alone does not provide that property, protect stored mailbox data, or secure an unlocked recipient device. Choose message encryption separately when those are requirements.

TLS also has a different job from SPF, DKIM, and DMARC. Those mechanisms help receiving systems evaluate sending domains and message authentication. A verified TLS connection does not establish that the visible From address is authorized, guarantee inbox placement, or prove that an email's links are safe.

When you change transport settings, you need both a connection check and a check of the email that follows. MailSlurp is an email testing platform with controlled inboxes and message inspection, so you can repeat the application workflow and inspect the received message after the TLS configuration is repaired.

Check SMTP TLS without sending an email

The following Python 3 script connects to one SMTP endpoint, verifies its certificate and hostname, and prints the negotiated TLS version. It does not authenticate or submit a message. Run it from the same environment as the application when you are investigating its network path or trust store.

Use a supported Python 3 installation and save the script as check_smtp_tls.py. It uses Python's standard-library SMTP client and a default verifying SSL context, with a 10-second socket-operation timeout.

import argparse
import smtplib
import ssl
import sys


def require_ehlo(client):
    code, message = client.ehlo()
    if code != 250:
        raise smtplib.SMTPHeloError(code, message)


def main():
    parser = argparse.ArgumentParser(description="Check SMTP TLS without sending mail")
    parser.add_argument("host")
    parser.add_argument("port", type=int)
    parser.add_argument("mode", choices=["implicit", "starttls"])
    args = parser.parse_args()
    if not 1 <= args.port <= 65535:
        parser.error("port must be between 1 and 65535")

    context = ssl.create_default_context()
    context.minimum_version = ssl.TLSVersion.TLSv1_2
    options = {"timeout": 10, "local_hostname": "tls-check.invalid"}
    try:
        if args.mode == "implicit":
            connection = smtplib.SMTP_SSL(
                args.host, args.port, context=context, **options
            )
        else:
            connection = smtplib.SMTP(args.host, args.port, **options)

        with connection as client:
            require_ehlo(client)
            if args.mode == "starttls":
                client.starttls(context=context)
                require_ehlo(client)
            version = client.sock.version()
        print(f"TLS verified: {version}; no authentication or message sent")
        return 0
    except (OSError, smtplib.SMTPException) as error:
        print(f"TLS check failed: {error}", file=sys.stderr)
        return 1


if __name__ == "__main__":
    sys.exit(main())

Replace smtp.example.com with the provider's actual submission hostname and run the command matching its documented setting:

python3 check_smtp_tls.py smtp.example.com 465 implicit

Or, for STARTTLS:

python3 check_smtp_tls.py smtp.example.com 587 starttls

A successful result means this connection passed the runtime's certificate and hostname checks and completed SMTP negotiation over TLS. It does not test login credentials, sending permissions, message delivery, or the server's other endpoints. The script exits with a failure if STARTTLS is absent, a certificate cannot be verified, or an SMTP/socket operation fails.

Fix a failed TLS check without weakening verification

A timeout can mean the host or port is wrong, the network blocks the connection, or the service is unavailable. If the connection opens but negotiation fails, check the port/mode pairing before changing account passwords. Authentication has not happened yet.

For a certificate error, check the exact submission hostname, certificate expiry, server certificate chain, application trust store, and machine clock. On a private mail service, install the organization's approved CA certificate in the runtime's trust store through its normal administration process. Do not disable hostname validation or accept any certificate as a workaround.

If STARTTLS is not advertised or negotiation fails, a submission client configured to require TLS should stop. Optional encryption can permit a downgrade to plaintext; RFC 3207's security discussion explains why capability advertisement alone is insufficient. Update the server or client configuration instead of allowing credentials to be sent without verified TLS.

Follow the secure connection through to receipt

After transport verification, run one application test addressed to a fresh MailSlurp inbox. Authenticate through the application's normal supported method, trigger the message once, and wait for receipt. If authentication or submission fails, preserve that response separately from the TLS result.

Inspect the received message and its headers with the email header analyzer. A trusted receiving server's Received entry may record TLS for its connection, but it does not prove every earlier hop validated a certificate or that no plaintext copy exists. Use send-side logs for the connection you control and avoid treating untrusted header entries as independent proof.

Finally, check the content the application depends on: correct recipient, expected sender, required code or link, and attachments. A TLS repair answers whether the connection is protected; receipt and content checks answer whether the email workflow works. If mail was accepted but remains delayed, inspect its queue and retry history before sending another copy.