SMTP Error: Could not authenticate 📝 WordPress

WordPress / PHPMailer: SMTP Error: Could not authenticate / SMTP connect() failed

The SMTP server rejected the login or couldn’t be reached — wrong credentials, app passwords required, wrong port/encryption, or outbound SMTP blocked.

Seen on: WordPress

Meaning

Gmail/Microsoft 365 require app passwords or OAuth; basic auth may be disabled. Hosts often block ports 25/465/587 outbound. Port and encryption must match (587+TLS, 465+SSL).

Common causes

  • Wrong username/password or app password needed
  • Provider disabled basic SMTP auth (Microsoft 365)
  • Port/encryption mismatch
  • Outbound SMTP ports blocked by host

⚡ Quick fix

  1. Use an app password or the provider’s OAuth/API mailer
  2. Match port and encryption (587 STARTTLS / 465 SSL)
  3. Test connectivity from the server

Detailed fix by platform

Shell

  1. php
    openssl s_client -starttls smtp -connect smtp.gmail.com:587 -crlf </dev/null | head -5
    nc -vz smtp.example.com 587

How to diagnose

  1. Credentials — App password?
  2. Network — Port reachable?
  3. Settings — Port/encryption pair

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.