Skip to content

Instantly share code, notes, and snippets.

@ara303
Created October 13, 2026 00:09
Show Gist options
  • Select an option

  • Save ara303/edeaa7d4c20effaf2ec5ff0ee48b4e32 to your computer and use it in GitHub Desktop.

Select an option

Save ara303/edeaa7d4c20effaf2ec5ff0ee48b4e32 to your computer and use it in GitHub Desktop.
Use SiteGround SMTP directly (without using SG's DNS)
The hostname came straight from the server itself. Every SMTP server announces its own name in its greeting banner — I just asked it. You don't need to guess or look it up anywhere.
The two commands that did it
1. Ask the server on the SMTP port:
printf 'EHLO test.local\r\n' | nc -G 6 mail.<domain_name>.co.uk 25
The reply was:
220-uk33.siteground.eu ESMTP #2 ...
250-uk33.siteground.eu Hello test.local ...
That first line after 220- is the server's canonical name — uk33.siteground.eu. That's the name on its own valid certificate. Done.
2. Confirm that name has a valid cert (before trusting it):
openssl s_client -connect uk33.siteground.eu:465 -servername uk33.siteground.eu </dev/null 2>&1 | grep "Verify return code"
Verify return code: 0 (ok)
0 (ok) means the cert is valid. I ran the same check against mail.<domain_name>.co.uk and got 10 (certificate has expired) — that contrast is what told me the name was the fixable variable, not the credentials or DNS.
The reasoning in order
1. Does the name resolve? dig +short mail.<domain_name>.co.uk → an IP. So DNS wasn't the issue.
2. Is anything actually listening? nc -z on the mail ports → all open. So it wasn't a firewall or blocked port.
3. Who am I really talking to? Read the SMTP banner → uk33.siteground.eu. That's the machine's real identity.
4. Which name has a good cert? Compare openssl s_client verify codes for both names → one expired, one valid. Swap to the valid one.
The general lesson
- nc + the protocol banner tells you what a server thinks it is. Works for SMTP, IMAP (* OK ...), FTP, SSH.
- openssl s_client ... | grep "Verify return code" is the fastest way to prove a TLS/cert problem. 0 (ok) vs anything else.
- When a hostname-based service fails but the port is open, try connecting by the machine's own hostname (from the banner, or dig -x <IP> for PTR). Certificates are often valid on the server's real name but stale on the custom vanity name.
- "Can't connect" from an app usually means the TLS handshake failed, not that TCP failed or credentials were wrong. The app's error message is often misleading — go verify the handshake yourself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment