Skip to content

530 5.7.0 Must issue a STARTTLS command first: what it means

530 5.7.0 Must issue a STARTTLS command first means your client tried to log in or send before encrypting the connection. Turn on STARTTLS or use implicit TLS.

Koltrix Team6 min read
Blue ethernet cables plugged into a network switch
Photo by Jordan Harrison on Unsplash
On this page(9 sections)
  1. What does "Must issue a STARTTLS command first" mean?
  2. Which of the four causes do you have?
  3. How do the ports and TLS modes line up?
  4. How do you see the problem on the wire?
  5. How do you fix it in common clients and libraries?
  6. What if the server is yours?
  7. What does this look like with the Koltrix SMTP relay?
  8. What is the difference between 530 5.7.0 and a 535?
  9. Bottom line

The reply 530 5.7.0 Must issue a STARTTLS command first means the SMTP server will not accept your login or your message until the connection is encrypted, and your client sent AUTH or MAIL FROM while it was still in plain text. The fix is almost always a client setting: turn on STARTTLS, or switch to a port that uses implicit TLS.

Nothing is wrong with your password, your domain or your reputation. The server is refusing to continue the conversation in the clear. This post explains what the error is, the four causes that account for nearly every case, and how to confirm which one you have in a minute.

What does "Must issue a STARTTLS command first" mean?

It means the server requires TLS and the client has not started it. STARTTLS is the SMTP extension that upgrades an existing plain-text connection to an encrypted one; it is defined in RFC 3207, which also names this exact reply: a server that insists on TLS may answer 530 Must issue a STARTTLS command first to commands sent too early.

A healthy session on a STARTTLS port runs in this order:

  1. The client connects and the server sends its 220 greeting.
  2. The client sends EHLO, and the server lists its capabilities, including STARTTLS.
  3. The client sends STARTTLS, and the server answers 220 Ready to start TLS.
  4. Both sides run the TLS handshake, then the client sends EHLO again.
  5. Only now does the client send AUTH, MAIL FROM, RCPT TO and DATA.

The 530 appears when the client jumps from step 2 to step 5. The first digit of 5.7.0 says the failure is permanent for this attempt, and the 7 class means a security or policy refusal; see SMTP enhanced status codes for how to read the rest.

Which of the four causes do you have?

Pick the row that matches your setup; each one has a one-line fix.

Cause What it looks like Fix
STARTTLS is switched off in the client Settings say "None" or "no encryption", or starttls.enable=false Set encryption to STARTTLS (sometimes labeled "TLS")
The setting is on but the library never sends it Works in a mail app, fails in your code Enable the library's STARTTLS option, or require it
Port and mode do not match STARTTLS configured on 465, or implicit TLS on 587 Match the mode to the port (table below)
A device in the middle strips STARTTLS Works from one network, fails from another Test from a different network; fix or exempt the firewall inspection

How do the ports and TLS modes line up?

Port 587 normally uses STARTTLS, port 465 uses implicit TLS, and port 25 is for server-to-server relay. Providers can also offer an alternative port; port 2525 is common, though it is not an IANA-assigned SMTP port.

Port TLS mode Client setting to use
587 STARTTLS (upgrade after connecting) "STARTTLS" or "TLS"
465 Implicit TLS (encrypted from the first byte) "SSL/TLS" or secure: true
25 Opportunistic STARTTLS between servers Not for applications
Provider-specific (for example 2525) Read the provider's docs Usually STARTTLS

RFC 8314 registers port 465 for submission over implicit TLS and recommends implicit TLS where it is available. Our ports 25, 465, 587 and 2525 guide goes through each port in more detail. The key point here: a client set to "SSL" on port 587 hangs or fails the handshake, and one set to "no encryption" on 587 produces the 530.

How do you see the problem on the wire?

Connect by hand and read what the server offers. This takes under a minute with OpenSSL:

openssl s_client -connect smtp.example.com:587 -starttls smtp -crlf -quiet

If that connects and you can type EHLO test.example.com and see AUTH advertised, the server is fine and your application is the part that skips the upgrade. To watch the unencrypted attempt fail, use a plain TCP connection and look at the capability list:

$ nc smtp.example.com 587
220 smtp.example.com ESMTP
EHLO test.example.com
250-smtp.example.com
250-STARTTLS
250 SIZE 26214400
AUTH PLAIN AHVzZXIAcGFzcw==
530 5.7.0 Must issue a STARTTLS command first

Note what is missing from that EHLO reply: there is no AUTH line, because the server hides authentication until TLS is on. If your own server logs show STARTTLS in the capability list followed by this 530, the client ignored it. Our Swaks and OpenSSL testing guide shows a complete authenticated test with swaks --tls.

How do you fix it in common clients and libraries?

Set the TLS mode explicitly instead of trusting a default, and make it required so a failed upgrade stops the send rather than falling back to plain text.

Client or library Setting
Nodemailer secure: false on 587 with requireTLS: true; secure: true on 465
Python smtplib SMTP(host, 587) then starttls() before login(); or SMTP_SSL(host, 465)
JavaMail (Jakarta Mail) mail.smtp.starttls.enable=true, and mail.smtp.starttls.required=true to fail closed
PHPMailer SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS with port 587
WordPress or CMS plugin Encryption dropdown set to "TLS" on 587 or "SSL" on 465
Command-line swaks --tls for STARTTLS, --tlsc for implicit TLS

A common trap is Nodemailer's secure flag: it means implicit TLS, so secure: false does not mean "no encryption". On 587 it still upgrades with STARTTLS, and requireTLS: true makes the upgrade mandatory.

What if the server is yours?

If you run the server and clients get this error, it is working as configured: it requires TLS before AUTH. Check three things. First, that the certificate is valid and its name matches the hostname clients use, because some libraries drop the upgrade when verification fails. Second, that no firewall or load balancer with "SMTP inspection" is removing STARTTLS from the capability list. Third, that you really want to allow plain AUTH at all: sending a password in the clear is the reason this refusal exists, so the better answer is to fix the clients rather than relax the server.

What does this look like with the Koltrix SMTP relay?

The Koltrix SMTP relay is at smtp.koltrix.com on port 2525 with STARTTLS (TLS 1.2 or later), and authenticates with an API key that has the send scope. The documented order is: connect, send EHLO, upgrade with STARTTLS, then authenticate. Most libraries do this automatically when told to use STARTTLS.

The docs note that the relay still accepts AUTH on an unencrypted connection so existing integrations keep working, but that this will be switched off, so upgrade before you log in; your API key is a password. Ports 587 and 465 are not the relay and do not accept API keys, which is one more reason to check the port when a login fails. For new code the REST API avoids the whole question; see SMTP relay vs HTTP API for the trade-offs, and email API key security for keeping the key safe.

A quick check that your key and TLS mode work together:

swaks --server smtp.koltrix.com --port 2525 --tls \
      --auth PLAIN --auth-user apikey --auth-password "$KOLTRIX_API_KEY" \
      --from [email protected] --to [email protected] \
      --header "Subject: STARTTLS test" --body "It works."

The --from address must be an active address on a verified domain in your workspace.

What is the difference between 530 5.7.0 and a 535?

A 530 says the server needs something first (TLS), before it will look at your credentials. A 535 says the server looked at the credentials and refused them. If you fix a 530 and then see a 535, you have progressed one step: the connection is now encrypted and the remaining problem is the username, the password, or a provider policy. Our posts on Gmail 535 5.7.8 and Microsoft 365 535 5.7.3 cover those next.

Bottom line

  • 530 5.7.0 Must issue a STARTTLS command first means the server requires encryption and your client sent AUTH or MAIL FROM too early.
  • The cause is almost always one of four: STARTTLS disabled, a library that skips it, a port and mode mismatch, or something on the network stripping the capability.
  • Match the mode to the port: STARTTLS on 587 (and most alternative ports), implicit TLS on 465.
  • Require TLS in your client so a failed upgrade stops the send instead of exposing the password.
  • Test by hand with openssl s_client -starttls smtp or swaks --tls before changing code.
  • After the 530 clears, a 535 means the credentials or provider policy are next.

Start with Koltrix

Your domain, one inbox, and an API that sends.

A team inbox where AI sorts and drafts (nothing is sent without your click), plus the transactional API and SMTP relay your product sends with. 7 days free, no card.

SharePost on XLinkedIn