Most “wrong password” tickets are not password problems. They are a firewall quietly dropping packets to port 993, a certificate chain that a client refuses to validate, or an auth mechanism the server never offered. The fix is not to retry credentials harder but to test the path in the order failures actually occur: reachability, then TLS, then authentication. Do that and you stop chasing ghosts.
Ports and SSL settings that actually matter
The protocol choice sets your ports. IMAP keeps mail on the server and uses encrypted port 993 for implicit TLS, while POP3 downloads mail to a single client and uses encrypted port 995. Plain-text 143 and 110 exist, but they belong behind STARTTLS upgrades at best, and most providers now refuse them outright. SMTP handles sending mail and lives on 587 with STARTTLS or 465 with implicit TLS. If you are wiring a scanner, a ticket importer, or an SEO crawler that reads verification emails, those are the four numbers to memorize: 993, 995, 587, 465.
The myth worth killing is that “SSL” is a single toggle. There are two distinct modes. Implicit TLS means the socket is encrypted from the first byte, which is what 993 and 995 expect. STARTTLS means you connect in the clear and then negotiate encryption on the same port, which is the norm on 587. Point an implicit-TLS client at a STARTTLS port, or the reverse, and you get a hang or an instant reset that looks nothing like an auth failure but gets reported as one. Match the mode to the port and half your mysterious errors evaporate.
Client defaults that quietly break automation
Here is the insider detail that saves hours: SEO automation tools default to POP3. That default is baked into libraries and older scripts because POP3 is simpler to implement, not because it is better. POP3 supports inbox only, so if your workflow depends on folders, labels, or read states, you are fighting the protocol. IMAP synchronizes folders and read states across devices, which is what you want when a bot and a human share a mailbox. Check the protocol setting before you debug anything else, because a POP3 client pointed at an IMAP-only account will fail in ways that mimic bad credentials.
The other default trap is port fallback. Many tools try 993, fail, and silently drop to 143 without telling you. Then TLS validation fails on a port that was never meant to carry implicit TLS, and the error log blames the certificate. Force the port explicitly. If the tool will not let you, that is a signal to replace the tool, not to loosen your TLS settings to compensate.
| Setting | Port | TLS mode | Use it when |
|---|---|---|---|
| IMAP | 993 | Implicit TLS | You need folder sync, read states, or multiple devices and bots sharing a mailbox |
| POP3 | 995 | Implicit TLS | Single client, inbox-only pull, or a legacy tool that only speaks POP3 |
| SMTP submission | 587 | STARTTLS | Sending mail with an upgrade to TLS after connect |
| SMTP submission | 465 | Implicit TLS | Sending mail from clients that expect TLS from the first byte |
| Legacy IMAP/POP3 | 143 / 110 | STARTTLS or none | Only as a fallback; avoid for anything carrying credentials |
Step one: prove the port is reachable before blaming anything else
Reachability is the cheapest test and the one most people skip. A firewall blocking port 993 produces a timeout, and a timeout gets misread as “the server rejected my login.” It did not reject anything; it never heard you. Test the TCP handshake first, with no TLS and no credentials in play. If the connection does not open, everything downstream is noise.
From a Linux or macOS box, use a raw socket test. nc -vz mail.example.com 993 tells you whether the three-way handshake completes. On Windows without netcat, Test-NetConnection mail.example.com -Port 993 in PowerShell does the same job and prints the resolved IP, which matters when a hostname points at a stale load balancer. Run the same test against 995 if you are on POP3. If 993 times out but 443 succeeds, you have a network policy problem, not a mail problem. Corporate networks and some cloud egress rules block non-standard ports by default.
Reading the three failure shapes
A timeout means packets are being dropped, usually by a firewall, security group, or ISP filter. A connection refused means packets arrived and the host actively rejected them, which points at the wrong hostname, the wrong port, or a service that is not listening. A connection that opens and then closes immediately is the interesting case: something is listening, but it expects a different protocol or TLS mode than you sent. Each shape narrows the next test. Do not move to TLS until the handshake completes, and do not move to auth until TLS is clean.
One more reachability check that catches a specific class of bug: verify DNS resolution matches what you expect. A catch-all domain routed through a provider like AllMail can have MX records pointing somewhere sensible while the imap vs pop3 hostname resolves to a different edge node. If dig +short mail.example.com returns an IP you do not recognize, stop and confirm the hostname against your provider’s documentation before testing anything else. Half of “intermittent” failures are DNS round-robin sending you to a node with a stale certificate.
Step two: verify the certificate chain with openssl s_client
Once the port opens, the next failure layer is TLS. A certificate that expired last week, a chain missing an intermediate, or a hostname mismatch all produce connection errors that clients report as vague “cannot connect” messages. The openssl s_client command shows you exactly what the server presents so you can judge it yourself instead of guessing from a client’s error string.
Run openssl s_client -connect mail.example.com:993 -servername mail.example.com -showcerts. The -servername flag is not optional when the server hosts multiple domains, because without SNI you may get a default certificate that does not match your hostname and conclude the certificate is broken when you simply asked for the wrong one. Read the output in order. Look for “Verify return code: 0 (ok)” at the bottom. Anything else, such as code 20 (unable to get local issuer certificate) or code 10 (certificate expired), tells you precisely what to fix. Code 20 on a working client usually means your local trust store is missing an intermediate, not that the server is misconfigured.
Check the dates and the names. The output prints “notBefore” and “notAfter” lines, and the subject and SAN fields show which hostnames the certificate covers. A certificate valid for *.mailprovider.com will not validate for mail.yourdomain.com even if the connection works, and some clients enforce that strictly while others do not. The gap between lenient and strict clients is why the same mailbox “works in Thunderbird but not in my script.” The certificate is not the variable; the validation policy is.
When to pin, when to fix the chain
Never disable verification to make an error go away. If the chain is broken, the fix is to install the missing intermediate on the server or update the client’s CA bundle. Pinning a certificate fingerprint is a legitimate choice for a locked-down automation host, but it trades convenience for maintenance: every certificate renewal breaks the pin until you update it. For most SEO automation and shared inbox workflows, standard chain validation against a current CA bundle is the right default. Save pinning for cases where you control both ends.
If s_client reports a clean chain but your application still fails TLS, the problem is in the application’s trust configuration, not the network or the server. Python’s ssl module, Node’s bundled CA store, and a system curl can each disagree about which roots to trust. Test with the same runtime your automation actually uses. A clean openssl result plus an application failure means you are debugging a library, and that is a different hunt.
Step three: authenticate only after the path is clean
With reachability proven and the certificate chain verified, authentication becomes a narrow problem. If login fails now, it is genuinely about credentials or the auth mechanism, and you can trust that conclusion. This ordering is the whole point: it prevents the common trap of resetting a password three times while a firewall blocks port 993. Reachability, then TLS, then auth. Failures surface in the order they actually happen.
Test auth directly with openssl s_client -connect mail.example.com:993 -crlf -quiet and then type the IMAP LOGIN command by hand. This removes your mail client from the equation entirely. A successful login returns a tagged OK. A failure returns NO with a reason, and the reason matters. “Authentication failed” is credentials. “LOGIN disabled” means the provider requires OAuth or an app-specific password. “Too many connections” is a rate limit, not a password problem. Reading the exact server response saves you from fixing the wrong thing.
Two auth details trip people up. First, many providers require an app-specific password when two-factor auth is enabled, and the account password will fail even though it is correct. Second, some servers advertise auth mechanisms the client does not support, and the negotiation fails before credentials are even sent. If you see a mechanism mismatch, check whether the provider expects PLAIN over TLS, LOGIN, or OAuth2. For a bot reading verification emails, an app password over implicit TLS on 993 is usually the simplest working configuration.
Protocol version is the last variable. IMAP4rev2 is defined by RFC 9051, and it supersedes the older IMAP4rev1 described in RFC 3501. POP3 is defined by RFC 1939 and has barely changed in decades, which is part of why it is so stable and so limited. If a modern client negotiates IMAP4rev2 and your server only speaks rev1, most clients fall back gracefully, but a few strict ones do not. When in doubt, check the server’s CAPABILITY response after connecting; it lists exactly what the server supports, including auth mechanisms and the protocol revision.
The practical sequence to keep on a sticky note: confirm DNS points where you think, prove the TCP handshake on 993 or 995, run openssl s_client with SNI and read the verify code, then authenticate by hand and read the exact server response. Each step isolates one layer, so the failure tells you where to look. Reachability first, TLS second, credentials last. That order turns a vague “mail is broken” into a specific, fixable fact, and it keeps you from loosening TLS settings or resetting passwords to solve problems that were never in those layers to begin with. If you are choosing a provider for automation, favor one that documents its ports, publishes a clean certificate chain, and supports app passwords, because good defaults remove most of these debugging steps before they start. The AllMail blog covers the provider-side details when you need to compare options.
