SMTP TLS certificate verification failed: hostname mismatch / unable to get local issuer (mail client or library)
The client verified the mail server's certificate and it didn't match the host name or wasn't trusted.
Hostname/IP does not match certificate's altnames SMTPcertificate verify failed: Hostname mismatch smtpSSL: certificate verify failed (SMTP)Error: Hostname/IP does not match certificate's altnames: Host: mail.example.com. is not in the cert's altnamesThe server's TLS certificate does not match Meaning
Connect using the exact host name in the certificate (e.g. smtp.provider.com, not a CNAME or IP), update the CA bundle, and make sure the server sends the full chain. Don't disable verification in production; for internal servers add the CA or a proper certificate.
Common causes
- Connecting by IP/alias not in the certificate
- Self-signed/internal CA certificate
- Expired or incomplete chain
- Old CA bundle
- Provider certificate rotation
⚡ Quick fix
- Use the host name from the certificate SAN
- Install the CA or fix the chain
- Update the CA bundle/runtime
Detailed fix by platform
Shell
openssl s_client -starttls smtp -connect smtp.example.com:587 -servername smtp.example.com 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName
How to diagnose
- Host — In SAN?
- Chain — Complete?
- CA bundle — Current?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 530 530 5.7.0 Must issue a STARTTLS command first (TLS required before AUTH or sending)
- 530 5.7.0 Authentication Required SMTP: 530 5.7.0 Must issue a STARTTLS command first / 530 5.7.1 Authentication required
- AH01909: server certificate does NOT include an ID which matches the server name Apache: [ssl:warn] AH01909: example.com:443:0 server certificate does NOT include an ID which matches the server name
Most viewed in Email / SMTP
- 550 5.7.1 550 5.7.1 Relaying denied / Message rejected as spam / Unauthenticated email not accepted
- Laravel: Connection could not be established with host Laravel: Symfony\Component\Mailer\Exception\TransportException: Connection could not be established with host "smtp.mailtrap.io:2525": stream_socket_client(): Unable to connect
- SES: Maximum sending rate exceeded Amazon SES: Throttling — Maximum sending rate exceeded (454 Throttling failure)
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026