checkimap
Check the IMAP hostname, its DNS record, and the SSL certificate on port 993, repair the mail SSL setup when the certificate is missing, and alert the administrator about hostname and DNS problems
- Command:
/go/checkimap - Category: Email
- Required option: None
- Output: A message when the hostname or DNS is wrong, otherwise nothing
- Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also
Overview
Email programs connect to your server's IMAP service on port 993 with SSL. For this to work, the IMAP hostname must be valid, must point to this server, and must have a matching SSL certificate. /go/checkimap tests all three, in that order. It:
- checks that the IMAP hostname in
/etc/imaphas a name and a domain - checks that the hostname's A record points to this server
- checks that the certificate on port 993 is for that hostname
- if the certificate does not match, installs the mail SSL certificate and the mail services again
When the hostname or DNS is wrong, it also alerts the administrator by email and WhatsApp.
Quick start
/go/checkimap
Syntax
/go/checkimap
The command takes no options or arguments. Run it as root.
Options
None. Any arguments you pass are ignored.
Output
The command prints nothing when everything is correct. Otherwise it prints one of these messages and stops with status 1:
| Message | Meaning |
|---|---|
Invalid IMAP Hostname (<hostname>), IMAP hostname should consist of a name and a domain name. All valid hostnames should have 2 dots in them. |
The hostname in /etc/imap has fewer than 2 dots, for example example.com. Use a name such as imap.example.com. |
Please Point <hostname> to A Record: <server-ip> |
The hostname does not resolve to this server's public IP address. |
Each of these two problems also sends the administrator an email and a WhatsApp message with the same text.
A certificate repair prints nothing of its own. You may see raw openssl messages on screen during the check. Each run adds a line to /var/log/go/checkimap.log.
Examples
# Check IMAP
/go/checkimap
# See which hostname the command checks
cat /etc/imap
# Check the A record yourself
dig imap.example.com +short
# See which certificate port 993 is using
openssl s_client -connect localhost:993 </dev/null 2>/dev/null | grep -i subject
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Invalid IMAP Hostname |
The hostname in /etc/imap has fewer than 2 dots. |
Use a hostname such as imap.example.com. |
Please Point ... to A Record |
The A record is missing or points to another IP. | Point the A record to the IP shown. |
| The A record is correct but the message still appears | The record is proxied through Cloudflare, so DNS returns a Cloudflare IP. | Set the record to DNS only. See proxy. |
| Nothing is printed, but mail apps show a certificate warning | The command only looks for the hostname in the certificate. It does not check the expiry date. | Renew the mail certificate with mailssl. |
| Certificate is not repaired | No Let's Encrypt certificate could be created for the hostname. | Check that the hostname points to this server and that port 80 is open, then run mailssl. |
| No alert arrives | The administrator's email or WhatsApp settings are missing. | Check them with config and email. |
dig: command not found |
The DNS tools are not installed. | Install the dnsutils package. |
Details
What it does, in order
- Logs the run to
/var/log/go/checkimap.log. - Reads the IMAP hostname from
/etc/imap. If it has fewer than 2 dots, prints the message, sends the alert, and stops. - Looks up the hostname's A record with
dig, and compares the last answer with this server's public IPv4 address. If they differ, prints the message, sends the alert, and stops. - Connects to
localhost:993withopenssland saves the answer. If the answer does not contain the IMAP hostname:- Runs
mailsslto install the SSL certificate for SMTP and IMAP. - If a Let's Encrypt certificate for the hostname now exists, runs
installmailto configure Postfix and Dovecot again. - If
mynetworksis missing from/etc/postfix/main.cf, runs the internalpostconfhelper andmail restart.
- Runs
Known issues
- The certificate check is a text search for the hostname. An expired certificate with the right name passes.
- If the A record has several addresses, only the last one is compared.
- In the email for an invalid hostname, the text names the server's host name instead of the IMAP hostname. The WhatsApp message names the IMAP hostname correctly.
- A certificate repair is not reported to the administrator.
- The exit status is
0after a repair attempt, even if the repair failed.
See also
| Command | Description |
|---|---|
checksmtp |
Check the SMTP port and SSL certificate |
mailssl |
Install SSL certificates for SMTP and IMAP |
installmail |
Install and configure webmail services (Postfix and Dovecot) |
troubleshoot |
Troubleshoot email problems in GoAdmio |
reversedns |
Check reverse DNS (rDNS) in GoAdmio |
proxy |
Change Cloudflare's proxy setting |