530 5.7.0 Error: Must Issue a STARTTLS Command First (Fix)
What the SMTP reply 530 5.7.0 Must issue a STARTTLS command first means, why apps, scripts and firewalls trigger it, and how to fix the port and TLS settings.

Your app, printer or script tries to send an email, and the server answers with "530 5.7.0 Must issue a STARTTLS command first". Nothing goes out. The message never reaches the recipient, so this is not a normal bounce from their side.
The good news is that the fix is almost always one setting. This guide explains what the error means, the usual causes, and how to fix it in common mail clients and code.
What 530 5.7.0 means#
The reply has two parts. 530 is the SMTP code for "authentication required". The server will not accept your message or your login until a condition is met.
5.7.0 is the enhanced status code. In RFC 3463, the 7 class covers security and policy, and .0 means "other or undefined". The text tells you which rule you broke: you must start encryption first.
STARTTLS is the SMTP command that turns a plain connection into an encrypted one. It is defined in RFC 3207. Gmail, Microsoft 365, Outlook.com and most hosts refuse to take a password or a message over a plain line. So when your client sends AUTH or MAIL FROM before STARTTLS, the server stops it.
Gmail shows the reply on several lines, like this:
530-5.7.0 Must issue a STARTTLS command first. For more
530-5.7.0 information, go to support.google.com
The common causes#
Encryption is turned off in the client#
The app has a setting such as "SSL/TLS: None" or "Use secure connection: No". It connects on port 587 or 25 and tries to log in right away. This is the cause in most cases, especially for printers, scanners and old apps.
The port and the TLS mode do not match#
There are two ways to encrypt mail submission:
- Port 587 with STARTTLS. The client connects in plain text, then upgrades. Settings often call this "TLS" or "STARTTLS".
- Port 465 with implicit TLS. The connection is encrypted from the first byte. Settings often call this "SSL".
If you pick port 587 but leave encryption off, you get this error. If you pick port 465 with STARTTLS mode, the connection usually hangs or fails with a different TLS error.
The code never calls STARTTLS#
Many mail libraries need you to ask for STARTTLS. If the line is missing, the library logs in over plain text, and the server refuses it.
A firewall hides STARTTLS#
Some firewalls inspect SMTP traffic and strip the STARTTLS line from the server's reply. The client thinks the server has no encryption, skips it, and is then refused. This is common with older network gear.
An Exchange or Postfix server sends to a host that requires TLS#
On your own mail server, the error can show up on outbound mail. The other side requires TLS, but your send connector or Postfix setup does not offer it, or has no valid certificate.
How to fix 530 5.7.0 step by step#
Step 1: Check the server, port and encryption#
Use the settings your mail host publishes. Google lists them in its guide to sending email from a printer, scanner or app. For Gmail, that means smtp.gmail.com on port 587 with TLS, or port 465 with SSL. Our guide to the Gmail port for SMTP covers the choices in more detail.
For Microsoft 365, use smtp.office365.com on port 587 with STARTTLS. Microsoft explains the options in its guide to sending email from a device or app.
Step 2: Turn on encryption in the client#
In Outlook, Thunderbird or a printer's web page, find the outgoing server settings. Set the encryption to "STARTTLS" or "TLS" for port 587. Set it to "SSL/TLS" for port 465. Save and send a test.
Step 3: Ask for STARTTLS in your code#
Each library has its own switch. Here are the common ones:
import smtplib
server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()
server.starttls() # upgrade before login
server.ehlo()
server.login(user, app_password)
// Nodemailer: port 587 uses STARTTLS
const transport = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 587,
secure: false,
requireTLS: true,
auth: { user, pass }
})
In PHPMailer, set $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS with port 587. In JavaMail, set mail.smtp.starttls.enable to true.
Step 4: Test the connection by hand#
Run this from the machine that sends the mail:
openssl s_client -starttls smtp -connect smtp.gmail.com:587 -crlf
If you get a certificate and a 250 reply, TLS works on that path. If it fails, a firewall or proxy may be in the way. To see what the server offers before TLS, connect with telnet and send EHLO. A healthy reply lists 250-STARTTLS. Our SMTP test guide shows the full process.
Step 5: Check the firewall#
If the STARTTLS line is missing, or looks like 250-XXXXXXXX, a firewall is likely rewriting the reply. Ask your network admin to turn off SMTP inspection for this traffic, then test again.
Step 6: Fix your own mail server#
On Exchange, check that the send connector can use TLS and has a valid certificate. On Postfix, set smtp_tls_security_level = may or encrypt, and point it to your certificate files. Then send a test to the domain that refused you.
Is this a bounce you need to act on in your list?#
No. The recipient address may be fine. The problem is the link between your sender and the mail server, so every message from that sender will fail until you fix it. Do not remove contacts because of this error.
How it compares with similar errors#
| Code | What it usually means |
|---|---|
| 530 5.7.0 (this error) | Encryption must start before login or sending |
| 535 5.7.8 | Encryption works, but the username or password is wrong |
| 530 5.7.1 | Login is required before sending |
| 550 5.7.1 | Policy or relay refusal by the recipient's server |
Once TLS works, you may hit the next step: a login error. Our guide to 535 5.7.8 username and password not accepted covers it. For other codes, see the full list of email bounce codes.
How to prevent it#
- Write down working settings. Keep the host, port and TLS mode for each app in one place.
- Prefer port 587 with STARTTLS, or 465 with TLS. Avoid port 25 for apps that log in.
- Update old devices. Old printers may not support current TLS versions. A relay service can help.
- Test after network changes. A new firewall can break mail that worked for years.
530 5.7.0 Checklist#
- Host, port and TLS mode match your provider's guide
- Encryption turned on in the client or code
-
openssltest shows TLS on port 587 or 465 -
EHLOreply lists STARTTLS - Firewall SMTP inspection checked
- Test message sent and received
FAQ#
What does 530 5.7.0 mean?#
It means the server wants an encrypted connection before it takes your login or your message. Turn on STARTTLS or TLS in your sending app.
Which port should I use?#
Use port 587 with STARTTLS, or port 465 with SSL/TLS. Both are encrypted. Pick the mode that matches the port.
Why does it work in Outlook but not in my script?#
Outlook asks for STARTTLS on its own. Many libraries do not. Add the STARTTLS call or option in your code.
Is my account blocked?#
No. This error comes before any login check. Fix the encryption setting first. If you then get a 535 error, check the password.
Can a firewall cause this error?#
Yes. Some firewalls hide the STARTTLS line in the server's reply. The client then skips encryption and the server refuses it.
Once your mail flows again, check your list with the Tomba Email Verifier so real bounces stay low.
// start free
See who Tomba finds at any company
Type a company's domain to see its people, their roles and verified work emails, each with the pages it was found on. Free account, no card.
Free plan · No credit card required · GDPR & CCPA
// about the author