"Must Issue a STARTTLS Command First" — Fixing TLS Email Errors

Getting '530 5.7.0 Must issue a STARTTLS command first' errors? Learn why this TLS requirement exists and how to configure your mail server for encrypted connections.

8 min readerrorsThomas Johnson

What This Error Means

The error 530 5.7.0 Must issue a STARTTLS command first means the receiving mail server requires TLS (Transport Layer Security) encryption, and your sending server attempted to deliver in cleartext. The receiving server refused the connection because your server either skipped the STARTTLS negotiation entirely or failed to upgrade the connection.

This is a permanent rejection (5xx status code). The message will not be delivered until your sending server successfully negotiates a TLS-encrypted connection.

The fix: enable TLS on your mail server, install a valid certificate, and ensure STARTTLS negotiation completes before sending.

How SMTP STARTTLS Works

SMTP was designed in 1982 without encryption. STARTTLS was added later (RFC 3207) as a way to upgrade a plaintext SMTP connection to an encrypted one without requiring a separate port. The handshake:

  1. Your mail server connects to the receiving server on port 25 (or 587 for submission)
  2. The receiving server responds with a greeting and advertises its capabilities via the EHLO response
  3. If the receiving server supports TLS, it includes 250-STARTTLS in its capabilities list
  4. Your server sends the STARTTLS command
  5. The receiving server responds with 220 Ready to start TLS
  6. Both sides perform a TLS handshake (certificate exchange, cipher negotiation)
  7. Once the encrypted channel is established, the SMTP conversation restarts over the secure connection

If your server skips step 4 and jumps straight to MAIL FROM, the receiving server rejects the attempt with 530 5.7.0.

Opportunistic vs. Mandatory TLS

Opportunistic TLS (the default for most server-to-server email) means the sending server tries STARTTLS if the receiver advertises it, but falls back to cleartext if TLS negotiation fails. This is how most email works today.

Mandatory TLS means the receiving server requires TLS and will not accept plaintext connections under any circumstances. When a server enforces mandatory TLS, failing to negotiate STARTTLS produces the 530 error. Major providers strongly prefer TLS and may enforce it for specific traffic classes or policy contexts. The bulk sender requirements make TLS effectively mandatory for high-volume senders.

Common Causes

Mail Server Not Configured for TLS

Your MTA (Mail Transfer Agent — Postfix, Exim, Exchange, etc.) does not have TLS enabled for outbound connections. This is common on older servers configured before TLS became widespread, or on fresh installations where TLS was not set up during initial configuration.

Outdated Mail Server Software

Very old mail server versions do not support modern TLS protocols. If your server only supports SSLv3 or TLS 1.0, the receiving server rejects the negotiation because those protocols have known vulnerabilities and are deprecated by most providers. Modern receivers typically require TLS 1.2 or higher.

Missing or Invalid TLS Certificate

STARTTLS requires your server to present a TLS certificate during the handshake. If:

  • No certificate is installed on the mail server
  • The certificate has expired
  • The certificate is self-signed and the receiving server requires a trusted certificate
  • The certificate's hostname does not match your mail server's hostname

...the TLS handshake may fail. Under opportunistic TLS (the default for most server-to-server email), many receivers accept self-signed or mismatched certificates. However, when strict validation is enforced — via MTA-STS, DANE, or the receiver's local policy — invalid certificates cause the connection to fail, and your server either falls back to cleartext (which the receiver then rejects) or aborts the connection entirely.

Firewall Blocking the TLS Negotiation

Some firewalls or security appliances perform deep packet inspection on SMTP traffic. Misconfigured firewalls can:

  • Strip the STARTTLS command from the SMTP conversation
  • Block the TLS handshake after STARTTLS is initiated
  • Interfere with the certificate exchange

This is common in corporate networks with aggressive outbound filtering. The SMTP session starts normally, but the TLS upgrade never completes.

Using Port 25 Without STARTTLS Support

Port 25 is the standard for server-to-server SMTP and supports STARTTLS as an upgrade. Some legacy configurations attempt to send on port 25 without issuing STARTTLS. If the receiving server mandates encryption on port 25, the connection is rejected.

Application-Level Email Sending

Applications that send email directly (using SMTP libraries in PHP, Python, Node.js, etc.) sometimes connect without enabling TLS in the SMTP client configuration. If the application sends through a relay that requires TLS, or directly to a receiver that mandates it, the 530 error occurs.

How to Fix It

Step 1: Enable TLS in Your MTA

Postfix:

In /etc/postfix/main.cf, ensure these settings are present:

smtp_tls_security_level = may
smtp_tls_loglevel = 1
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

Setting smtp_tls_security_level = may enables opportunistic TLS for all outbound connections. Postfix attempts STARTTLS whenever the receiver advertises it. For mandatory TLS to specific destinations, use smtp_tls_policy_maps.

Exim:

In the Exim configuration, ensure the transport for remote delivery includes:

tls_certificate = /etc/ssl/certs/exim.pem
tls_privatekey = /etc/ssl/private/exim.key

And the remote_smtp transport should have hosts_try_tls = * to attempt TLS with all hosts.

Exchange Server (on-premises):

In Exchange Management Shell, verify the send connector is configured for TLS:

Get-SendConnector | Format-List Name, TlsDomain, RequireTLS, TlsAuthLevel

If RequireTLS is $false, update it:

Set-SendConnector -Identity "Outbound" -RequireTLS $true

Step 2: Use the Correct Port

For email submission (client-to-server, such as applications sending email through a relay):

Port Protocol TLS Method
587 SMTP Submission STARTTLS (upgrade from plaintext)
465 SMTPS Implicit TLS (encrypted from the start)
25 SMTP STARTTLS (server-to-server delivery)

Port 587 with STARTTLS is the standard for email submission. Port 465 with implicit TLS is an alternative that some providers prefer. Port 25 is for server-to-server relay, not for application submission.

If your application sends on port 25 and hits the 530 error, switch to port 587 with STARTTLS or port 465 with implicit TLS.

Step 3: Install a Valid TLS Certificate

Obtain a TLS certificate from a trusted certificate authority. Let's Encrypt provides free certificates accepted by all major mail servers:

  1. Generate a certificate for your mail server's hostname (e.g., mail.yourdomain.com)
  2. Install the certificate and private key in your MTA's configuration
  3. Set up automatic renewal (Let's Encrypt certificates expire every 90 days)
  4. Ensure the certificate chain is complete (include intermediate certificates)

When strict validation is enforced (via MTA-STS or DANE), the certificate must match the expected receiving MX hostname or policy identity. Under opportunistic TLS, hostname mismatches are typically accepted.

Step 4: Check Firewall Rules

If you suspect firewall interference:

  • Ensure outbound connections on ports 25, 465, and 587 are allowed
  • Disable SMTP inspection or deep packet inspection rules that interfere with STARTTLS
  • Test from outside the firewall to confirm the issue is firewall-related
  • Check for transparent proxies that intercept SMTP traffic

Step 5: Verify

Use the mxio SMTP Server Test to verify that your mail server advertises STARTTLS and successfully negotiates TLS on ports 25, 465, and 587. Then send a test email and analyze the headers with the mxio Header Analyzer. Look for TLS or ESMTPS in the Received headers — this confirms the connection was encrypted. Also verify that your sending IP has a valid PTR record, since many receivers that enforce TLS also check reverse DNS.

MTA-STS: The Enforcement Mechanism

MTA-STS (Mail Transfer Agent Strict Transport Security, RFC 8461) allows receiving domains to declare that they require TLS for inbound email. When a domain publishes an MTA-STS policy, sending servers are expected to:

  1. Only connect over TLS (STARTTLS required)
  2. Validate the receiving server's TLS certificate against a trusted CA
  3. Refuse to deliver in cleartext, even if TLS negotiation fails

MTA-STS is published via a DNS TXT record (_mta-sts.domain.com) and a policy file served over HTTPS (https://mta-sts.domain.com/.well-known/mta-sts.txt). Major providers including Google and Microsoft publish MTA-STS policies.

If the receiving domain has MTA-STS enabled and your server cannot negotiate TLS, senders that cannot negotiate TLS may defer or fail delivery; the exact SMTP response varies by implementation. The fix is always on the sending side: enable TLS and ensure your certificates are valid.

Prevention and Ongoing Monitoring

TLS configuration is a set-and-forget concern until certificates expire or infrastructure changes. The most common cause of recurring STARTTLS failures is an expired certificate that nobody noticed.

  • Automate certificate renewal — Use Let's Encrypt with certbot or a similar ACME client. Manual certificate management leads to outages.
  • Monitor certificate expiry — Set up domain health monitoring to track your mail server's TLS status alongside your DNS authentication records
  • Test after infrastructure changes — Any change to mail server software, firewall rules, or network topology should be followed by a TLS verification test
  • Review mail logs regularly — Check for TLS handshake failures in your MTA logs, especially after provider-side changes
Was this article helpful?

Related Articles