ssl-guides 2026-12-02 ⏱ 4 min read

Install SSL on a Mail Server

Install SSL on a Mail Server

SSL on a mail server needs a certificate for the hostname clients and MX records use, then Postfix and Dovecot pointed at the same files.

Step 1: Choose the hostname

Clients configure a mail server name such as mail.example.com. Other mail servers find yours through the MX record, which also points at a hostname. The certificate must contain the name that clients and MX lookups use. A certificate for example.com alone will fail validation for mail.example.com unless that name is also listed. Make sure DNS for that hostname exists and that its reverse DNS matches; mail servers check this for other reasons too.

Step 2: Get a certificate

A free certificate from Let's Encrypt works for mail. HTTP validation needs a web server on port 80 for that name; DNS validation works without one. If HTTP validation fails, see fixing DNS validation errors. The Certbot basics are in this guide.

SSL mail server, step 3: Postfix

Add the files to /etc/postfix/main.cf:

smtpd_tls_cert_file = /etc/ssl/mail/fullchain.pem
smtpd_tls_key_file  = /etc/ssl/mail/privkey.pem
smtpd_tls_security_level = may
smtpd_tls_protocols = >=TLSv1.2
smtpd_tls_loglevel = 1

smtp_tls_security_level = may
smtp_tls_loglevel = 1

may means opportunistic TLS: Postfix offers encryption to anyone who asks but still accepts plain connections from other servers on port 25, because many senders cannot do TLS. Mail submission from your own users (port 587 or 465) should require encryption instead; the submission entries in master.cf can set smtpd_tls_security_level=encrypt. Our Configure SSL for SMTP covers ports in detail. Reload with postfix reload.

SSL mail server, step 4: Dovecot

In /etc/dovecot/conf.d/10-ssl.conf:

ssl = required
ssl_cert = </etc/ssl/mail/fullchain.pem
ssl_key  = </etc/ssl/mail/privkey.pem
ssl_min_protocol = TLSv1.2

The leading < before the path is part of Dovecot syntax: it tells Dovecot to read the file contents. Newer Dovecot releases rename some of these settings, so check the documentation for your installed version. Reload with systemctl reload dovecot.

Step 5: Test each service

ServiceCommand
SMTP on 25openssl s_client -starttls smtp -connect mail.example.com:25
Submission on 587openssl s_client -starttls smtp -connect mail.example.com:587
IMAPS on 993openssl s_client -connect mail.example.com:993
IMAP STARTTLS on 143openssl s_client -starttls imap -connect mail.example.com:143
POP3S on 995openssl s_client -connect mail.example.com:995

In each output, look for Verification: OK and confirm the subject matches your mail hostname. The OpenSSL testing guide explains how to read the results.

Step 6: Reload on renewal

Postfix and Dovecot read certificates only at startup or reload. After a renewal they will serve the old certificate until reloaded. Add a deploy hook that runs both reload commands; see automating renewal with Certbot. Also protect the key: it should be readable only by root or the services that need it, as described in how to protect SSL private keys.

Common problems

  • Mail clients warn about a name mismatch: the certificate lacks the hostname clients use.
  • Other servers deliver without TLS: expected on port 25 with may; look at your logs to see which senders support it.
  • Clients cannot connect after renewal: the service was not reloaded, or the new key file has wrong permissions.
  • Outlook or phone clients reject an incomplete chain: use the full chain file.

Webmail and other services

If you run webmail on the same host, it is a web service and needs its own certificate setup in Nginx or Apache. It can share the same certificate if the hostname is covered. Keep the same renewal hook reloading every service that reads the files: the web server, Postfix and Dovecot.

Finally, remember that TLS protects the connection between two servers, not the message at rest. It stops casual interception on the path, which is exactly what you want it for.

Related reading: installing a certificate on OVHcloud, free SSL on AWS and monitoring many certificates.

Frequently Asked Questions

Which hostname goes in the certificate?

The one clients and MX records use, usually mail.example.com. A certificate for example.com alone fails validation for the mail hostname.

Can Postfix and Dovecot share one certificate?

Yes, when it covers the hostname both use. Point both services at the same fullchain and key files.

What has to happen after renewal?

Reload both services. Postfix and Dovecot read the files at start, so a renewal without a reload leaves the old certificate in place.

🔒 Test Your Website SSL Certificate Now
Run Free SSL Check →

✅ Post-Installation Verification & SEO Checklist

After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:

  • Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
  • Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
  • Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
  • Confirm both root and www versions resolve cleanly to one canonical HTTPS URL.
  • Verify your HTTPS property and sitemap.xml inside Google Search Console and Bing Webmaster Tools.
Technically Reviewed by TryFreeSSL Security Team
Last updated: 2026-12-05
About Us →

Free SSL Certificates, Live SSL Checker & CSR Generator

Issue trusted Let's Encrypt SSL certificates in 60 seconds with zero server setup.

Related Articles

🤖 TryFreeSSL AI Assistant