Certificate Expired or Invalid in a Mac Email Client (IMAP)
Fix "certificate is expired or invalid" when adding an IMAP account on a Mac: Wi-Fi login pages, wrong server names, clock errors, and real server faults.
Updated 6 min read
On this page
You set up an IMAP account on your Mac, and the app stops with a message like this:
certificate is expired or invalidMailloft words the same failure in two ways: "The server's security certificate isn't trusted. It may be expired or self-signed, or a Wi-Fi login page may be in the way." and "The server's security certificate is for a different server name. Check the server name in the account settings." Other clients use their own wording, but the causes and fixes below apply to any app that connects over IMAP and SMTP. Where Mailloft has a specific control, we name it.
Why a mail app says the certificate is expired or invalid
When your app connects over SSL/TLS or STARTTLS, the server presents a certificate that says who it is. The app stops if any of these is true:
- The certificate is outside its validity dates.
- It was issued for a different host name than the one the app connected to.
- It comes from an authority your Mac doesn't trust, such as a self-signed certificate.
Stopping there protects your password from going to something that may not be your mail server. In Mailloft, an account that already exists shows "Security problem" under its name in the sidebar, with the reason in a tooltip.
| Cause | Typical symptom | Fix |
|---|---|---|
| Captive portal or filtering proxy | Error only on hotel, café, office or school Wi-Fi | Sign in to the network, or switch networks |
| Wrong server name | "Different server name" wording, or hand-typed servers | Copy exact names from your provider |
| Wrong Mac clock | Error on every network, other secure sites misbehave | Turn on automatic date and time |
| Port and security mismatch | "Does not support STARTTLS" or "couldn't be established" | Match security type to the port |
| Server certificate lapsed or self-signed | Every network, every device, correct settings | Provider or admin must renew it |
Fix 1: Check for a Wi-Fi login page
Symptom: the error appears on hotel, café, airport, office or school Wi-Fi, or right after joining a new network.
Why: a captive portal answers your connection with its own page and certificate until you sign in. Your app sees a certificate that isn't your mail provider's.
- Open a browser and load any normal website. If a sign-in or terms page appears, complete it.
- Return to your mail app and try again.
- If no page appears, try another network, such as a phone hotspot. If the error disappears, the first network was interfering.
A VPN or a filtering proxy that inspects encrypted traffic can produce the same error. Turn it off briefly to test.
Fix 2: Check the server name
Symptom: the message says the certificate is for a different server name, or you typed the server names by hand.
Why: a certificate is issued for specific host names. If the app connects to mail.example.com but the certificate covers another name, the check fails.
- Copy the exact incoming (IMAP) and outgoing (SMTP) server names from your provider's help pages. Don't guess them.
- Look for typos and stray spaces.
- Confirm the port and security type match what your provider lists. Common pairs are SSL/TLS on 993 (IMAP) and 465 (SMTP), or STARTTLS on 143 and 587.
In Mailloft
For the built-in providers (iCloud, Gmail, Fastmail, Yahoo, Outlook), the servers are filled in for you. For any other domain, Mailloft guesses imap.<domain> and smtp.<domain>, and a wrong guess is a likely source of this error.
- On the Servers step of Add a Mail Account, Mailloft runs Test Connection automatically when you arrive.
- Click Edit…, enter the server names your provider gives you, and click Test Connection again.
- After a failure on a custom domain, Mailloft may offer Try mail.
<domain>instead.
For an account you already added, choose Edit Account… from the account's "…" menu in the sidebar, or Edit… in Settings ▸ Accounts.
Fix 3: Check your Mac's date and time
Symptom: the error appears on every network, and other secure sites also behave oddly.
Why: a certificate is valid only between two dates. If your Mac's clock is wrong, a valid certificate can look expired.
- Open System Settings and search for "Date & Time".
- Turn on automatic date and time.
- Retry the account.
Fix 4: Match the security type to the port
Symptom: you see related messages such as "The server does not support STARTTLS." or "A secure connection to the mail server couldn't be established."
Why: the port and security type don't agree. Ports 993 and 465 usually expect SSL/TLS; ports 143 and 587 usually expect STARTTLS. Mailloft also closes the connection with "The server sent unencrypted data before the TLS handshake" if a server misbehaves before encryption starts.
- In the server settings, set the security type to match the port in your provider's documentation.
- Run Test Connection again.
Fix 5: The server really has a bad certificate
Symptom: the error happens on every network, the clock is right, the server names match your provider's documentation, and a colleague or a second device sees the same problem.
Why: the provider or your company's mail host may have let the certificate lapse, or may use a self-signed one. This is a server-side problem and the fix belongs on the server.
- If you run the server or use a small host, renew or replace the certificate with one from a public certificate authority, then retry.
- If someone else runs it, ask them. Give them the exact server name, the port and the message you see.
Checklist before you try again
- You have signed in to any Wi-Fi login page, or tested on a phone hotspot.
- VPNs and filtering proxies are off for the test.
- Your Mac's date and time are set automatically.
- Server names are copied from your provider, with no typos or spaces.
- The security type matches the port (SSL/TLS with 993 and 465, STARTTLS with 143 and 587).
- You are using the app password or sign-in method your provider requires.
After the certificate error is gone
A certificate error is separate from a sign-in error. Gmail, iCloud, Fastmail and Yahoo accounts in Mailloft sign in with an app password, so once the connection works you may still need one. See Create an app password for Gmail, iCloud, Fastmail or Yahoo. For Outlook and Microsoft 365, see Outlook, Hotmail and Microsoft 365 accounts in Mailloft.
If nothing works
Contact your mail provider or administrator if the error persists on several networks with a correct clock and correct server names. If another mail app connects to the same account on the same network but Mailloft doesn't, contact us through support.
Include the exact message text, the provider, the server names and ports, the security type, the network you were on and what you already tried. You can copy this:
Subject: Certificate error when connecting to my IMAP/SMTP server
Hello,
My mail app reports: "certificate is expired or invalid".
Account: you@example.com
Incoming server: imap.example.com, port 993, SSL/TLS
Outgoing server: smtp.example.com, port 465, SSL/TLS
Seen on: home Wi-Fi and a phone hotspot, since [date]
Mac date and time: set automatically
Already tried: checked for a login page, re-copied server names,
tested another network.
Can you confirm the certificate on these servers is valid and
issued for these host names?Common questions
Can I just accept the certificate and continue?
Mailloft doesn't offer a bypass for untrusted certificates. The fix is to correct the server name, the network or the server's certificate itself.
Why does it work in a browser but not in my mail app?
The browser may be loading your provider's website, which has a different certificate from the mail servers. A web login working says nothing about the IMAP or SMTP host names.
Is this the same as a wrong password error?
No. A certificate error happens before sign-in, while the connection is being secured. A password error comes after the connection succeeds.
Does Mailloft's guess for custom domains always work?
No. It guesses imap.<domain> and smtp.<domain>, which many hosts don't use. Enter the names your provider documents under Edit….