Docs / Email Servers / Let's Encrypt SSL for Mail Services

Let's Encrypt SSL for Mail Services

By Admin · Apr 3, 2026 · Updated Apr 23, 2026 · 5 views · 3 min read

Let's Encrypt SSL for Mail Services is a common requirement for VPS administrators. This guide provides practical instructions that you can follow on Ubuntu 22.04/24.04 or Debian 12, though most steps apply to other distributions as well.

Prerequisites

  • Valid PTR (reverse DNS) record configured
  • Basic familiarity with the Linux command line
  • A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
  • Root or sudo access to the server

Server Installation

It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.


# Install Postfix and Dovecot
sudo apt update
sudo apt install -y postfix dovecot-core dovecot-imapd dovecot-lmtpd

# Configure Postfix main.cf
sudo postconf -e 'myhostname = mail.example.com'
sudo postconf -e 'mydomain = example.com'
sudo postconf -e 'smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem'
sudo postconf -e 'smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem'

Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.

Authentication Setup (SPF/DKIM)

The letsencrypt configuration requires careful attention to resource limits and security settings. On a VPS with limited resources, it's important to tune these parameters according to your available RAM and CPU cores.


# Generate DKIM key
sudo apt install -y opendkim opendkim-tools
sudo mkdir -p /etc/opendkim/keys/example.com
sudo opendkim-genkey -b 2048 -d example.com -D /etc/opendkim/keys/example.com -s default -v

# Add the DNS TXT record from:
cat /etc/opendkim/keys/example.com/default.txt

Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.

Client Configuration

The letsencrypt configuration requires careful attention to resource limits and security settings. On a VPS with limited resources, it's important to tune these parameters according to your available RAM and CPU cores.


# Install Postfix and Dovecot
sudo apt update
sudo apt install -y postfix dovecot-core dovecot-imapd dovecot-lmtpd

# Configure Postfix main.cf
sudo postconf -e 'myhostname = mail.example.com'
sudo postconf -e 'mydomain = example.com'
sudo postconf -e 'smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem'
sudo postconf -e 'smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem'

These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.

Important Notes

After applying these changes, monitor the server's resource usage for at least 24 hours to ensure stability. Tools like htop, iostat, and vmstat can provide real-time insights into system performance.

Spam Filtering

The ssl component plays a crucial role in the overall architecture. Understanding how it interacts with letsencrypt will help you make better configuration decisions.


# Generate DKIM key
sudo apt install -y opendkim opendkim-tools
sudo mkdir -p /etc/opendkim/keys/example.com
sudo opendkim-genkey -b 2048 -d example.com -D /etc/opendkim/keys/example.com -s default -v

# Add the DNS TXT record from:
cat /etc/opendkim/keys/example.com/default.txt

Note that file paths may vary depending on your Linux distribution. The examples here are for Debian/Ubuntu; adjust paths accordingly for RHEL/CentOS-based systems.

Configuration Options

It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.

Next Steps

With letsencrypt now set up and running, consider implementing monitoring to track performance metrics over time. Regularly review your configuration as your workload changes and scale resources accordingly.

Was this article helpful?