GoAdmio

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

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:

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

  1. Logs the run to /var/log/go/checkimap.log.
  2. Reads the IMAP hostname from /etc/imap. If it has fewer than 2 dots, prints the message, sends the alert, and stops.
  3. 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.
  4. Connects to localhost:993 with openssl and saves the answer. If the answer does not contain the IMAP hostname:
    1. Runs mailssl to install the SSL certificate for SMTP and IMAP.
    2. If a Let's Encrypt certificate for the hostname now exists, runs installmail to configure Postfix and Dovecot again.
    3. If mynetworks is missing from /etc/postfix/main.cf, runs the internal postconf helper and mail restart.

Known issues


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