{"id":2052,"date":"2025-11-17T16:02:15","date_gmt":"2025-11-17T16:02:15","guid":{"rendered":"https:\/\/blog.eu.enginyr.ing\/?p=2052"},"modified":"2025-11-17T20:45:27","modified_gmt":"2025-11-17T20:45:27","slug":"email-infrastructure-setup-exim-configuration-on-linux-vps-complete-sysadmin-playbook","status":"publish","type":"post","link":"https:\/\/www.serverspan.com\/en\/blog\/email-infrastructure-setup-exim-configuration-on-linux-vps-complete-sysadmin-playbook\/","title":{"rendered":"Email Infrastructure Setup: Exim Configuration on Linux VPS (Complete Sysadmin Playbook)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Configuring Exim as a production mail transport agent on a Linux VPS requires precision: one misconfigured ACL or transport rule can turn your server into an open relay or cause legitimate mail to vanish into queue purgatory. This playbook gives sysadmins a complete, production-ready Exim configuration for a VPS environment\u2014covering everything from basic installation to advanced ACLs, SMTP authentication, TLS hardening, and relay architecture. Whether you&#8217;re building a standalone mail server or integrating Exim into a cPanel\/WHM ecosystem, these configurations are tested on Debian\/Ubuntu and CentOS\/RHEL systems running on <a href=\"https:\/\/www.enginyring.com\/en\/virtual-servers\">ENGINYRING Virtual Servers<\/a>, which provide the dedicated resources and network stability that mail servers demand.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unlike Postfix&#8217;s monolithic architecture, Exim uses a router-transport model that gives fine-grained control over mail flow. This granularity is powerful but demands exact configuration. We&#8217;ll configure Exim to handle local delivery, outbound relay through a smarthost, SMTPAUTH for client submission, and comprehensive ACLs to block spam and unauthorized relay attempts\u2014all while maintaining the performance and reliability your VPS hosting customers expect. For broader context on keeping your VPS secure while running mail services, see our <a href=\"https:\/\/www.enginyring.com\/en\/blog\/how-to-secure-a-vanilla-vps-a-comprehensive-guide-for-linux-beginners\">comprehensive VPS security guide<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installation and initial configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before touching Exim&#8217;s configuration files, verify your VPS meets the prerequisites: a clean Linux installation (Debian 11\/12, Ubuntu 22.04\/24.04, or CentOS 8+\/RHEL 9), a static public IP with proper PTR record, and DNS MX\/SPF records configured for your domain. Misconfigured DNS is the root cause of 80% of mail delivery failures. Our guide on <a href=\"https:\/\/www.enginyring.com\/en\/blog\/what-is-a-dns-record-a-beginners-guide-to-the-internets-phonebook\">DNS records fundamentals<\/a> covers the basics you need before sending a single email.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Package installation<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Debian\/Ubuntu\nsudo apt update && sudo apt install exim4 exim4-daemon-heavy exim4-config\n\n# CentOS\/RHEL\nsudo dnf install exim<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>exim4-daemon-heavy<\/code> on Debian\/Ubuntu for full feature support including content scanning and advanced ACLs. The light variant strips critical functionality needed for production anti-spam and authentication.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Initial configuration wizard<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run Exim&#8217;s configuration wizard to establish baseline settings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dpkg-reconfigure exim4-config  # Debian\/Ubuntu only<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select <strong>&#8220;mail sent by smarthost; no local mail&#8221;<\/strong> for relay-only setups<\/li>\n\n\n\n<li>Select <strong>&#8220;internet site; mail is sent and received directly using SMTP&#8221;<\/strong> for full mail server<\/li>\n\n\n\n<li>Enter your VPS FQDN (e.g., <code>mail.yourdomain.com<\/code>)<\/li>\n\n\n\n<li>Specify IP addresses to listen on (leave blank for all IPv4)<\/li>\n\n\n\n<li>Define other destinations for which mail is accepted<\/li>\n\n\n\n<li>Configure smarthost if using relay (e.g., <code>smtp.sendgrid.net::587<\/code>)<\/li>\n\n\n\n<li>Keep number of DNS queries minimal: <strong>Yes<\/strong> (reduces latency)<\/li>\n\n\n\n<li>Split configuration into smaller files: <strong>Yes<\/strong> (enables modular management)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This wizard generates <code>\/etc\/exim4\/update-exim4.conf.conf<\/code> (Debian\/Ubuntu) or <code>\/etc\/exim\/exim.conf<\/code> (CentOS\/RHEL). The split configuration model creates separate files under <code>\/etc\/exim4\/conf.d\/<\/code> for routers, transports, and ACLs\u2014use this for production environments. For detailed PTR record configuration, which is critical for mail deliverability, reference our tutorial on <a href=\"https:\/\/www.enginyring.com\/en\/blog\/how-to-configure-rdns-and-ptr-records-a-comprehensive-tutorial\">how to configure rDNS and PTR records<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Core architecture: routers and transports<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Exim&#8217;s mail flow follows a strict pipeline: routers determine destination, and transports execute delivery. Misconfiguration at any stage breaks the chain. We&#8217;ll configure each component for a typical VPS scenario: local delivery for system users, outbound relay through a smarthost, and SMTP submission for authenticated clients.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Router configuration (local delivery)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Routers handle mail routing decisions including local delivery to system users. Edit <code>\/etc\/exim4\/conf.d\/router\/00_exim4-config_local_user<\/code> (Debian\/Ubuntu) or add to <code>\/etc\/exim\/exim.conf<\/code> (CentOS\/RHEL):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Local user delivery router\nlocaluser:\n  driver = accept\n  check_local_user\n  domains = +local_domains\n  transport = local_delivery\n  cannot_route_message = Unknown user<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This router accepts mail for local domains and passes it to the local_delivery transport. The <code>check_local_user<\/code> option verifies the recipient exists in <code>\/etc\/passwd<\/code>, preventing bounce loops.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Router configuration (outbound routing)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For VPS setups, configure smart host routing for outbound and DNS-based routing for inbound. Edit <code>\/etc\/exim4\/conf.d\/router\/200_exim4-config_primary<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Smarthost router (outbound)\nsend_via_smarthost:\n  driver = manualroute\n  domains = !+local_domains\n  transport = remote_smtp_smarthost\n  route_list = * smtp.sendgrid.net::587\n  host_find_failed = defer\n  same_domain_copy_routing = yes\n  no_more\n\n# DNS lookup router (direct delivery)\ndnslookup:\n  driver = dnslookup\n  domains = !+local_domains\n  transport = remote_smtp\n  ignore_target_hosts = 0.0.0.0 : 127.0.0.0\/8\n  no_more<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The first router forces outbound mail through a smarthost (e.g., SendGrid, AWS SES) for deliverability. The second handles direct SMTP delivery when smarthost isn&#8217;t configured. The <code>ignore_target_hosts<\/code> prevents routing loops. Understanding these routing mechanics is part of mastering <a href=\"https:\/\/www.enginyring.com\/en\/blog\/what-is-a-virtual-server-a-guide-to-virtualization-types\">virtual server infrastructure<\/a> for hosting providers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Transport configuration (delivery execution)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Transports execute the actual delivery. Configure separate transports for local delivery, smarthost relay, and direct SMTP. Edit <code>\/etc\/exim4\/conf.d\/transport\/30_exim4-config_local_delivery<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Local Maildir delivery\nlocal_delivery:\n  driver = appendfile\n  directory = $home\/Maildir\n  maildir_format\n  delivery_date_add\n  envelope_to_add\n  return_path_add\n  user = ${extract{2}{:}{${lookup{$local_part}lsearch{\/etc\/passwd}}}}\n  group = mail\n  mode = 0660\n  mode_fail_hardlink = false\n\n# Smarthost SMTP transport\nremote_smtp_smarthost:\n  driver = smtp\n  port = 587\n  hosts_require_auth = smtp.sendgrid.net\n  hosts_require_tls = smtp.sendgrid.net\n\n# Direct SMTP transport\nremote_smtp:\n  driver = smtp\n  interface = ${if exists{\/etc\/mailips}{${lookup{$sender_address_domain}lsearch{\/etc\/mailips}{$value}{}}}{}}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The local delivery transport writes to Maildir format with proper permissions. The smarthost transport enforces authentication and TLS. The direct SMTP transport binds to a specific interface if configured. For larger deployments, consider our guide on <a href=\"https:\/\/www.enginyring.com\/en\/blog\/vps-hosting-for-multi-tenant-applications-apache-virtual-hosts-vs-nginx-server-blocks\">multi-tenant VPS applications<\/a> to architect mail infrastructure that scales.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ACL configuration: security and spam prevention<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">ACLs (Access Control Lists) are Exim&#8217;s primary defense against spam, relay abuse, and malformed messages. They run at SMTP connection, HELO, RCPT, and DATA stages. A misconfigured ACL can silently drop legitimate mail or expose your VPS to relay attacks. These ACLs work in conjunction with proper <a href=\"https:\/\/www.enginyring.com\/en\/blog\/what-is-dmarc-how-to-configure-it-and-why-a-poor-dmarc-record-can-spell-disaster\">DMARC configuration<\/a> for comprehensive email security.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Connection-level ACLs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>\/etc\/exim4\/conf.d\/acl\/30_exim4-config_check_rcpt<\/code> to block abusive connections early:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># RCPT ACL with connection rate limiting\nacl_check_rcpt:\n  # Accept if no IP address (local submission)\n  accept\n    hosts = :\n    control = dkim_disable_verify\n\n  # Deny if too many connections from this IP\n  deny\n    message = Too many connections from your IP\n    condition = ${if >{${eval:$rcpt_count+1}}{50}}\n\n  # Accept authenticated users\n  accept\n    authenticated = *\n    control = submission\/sender_retain\n    control = dkim_disable_verify\n\n  # Accept for local domains\n  accept\n    domains = +local_domains\n    endpass\n    verify = recipient\n\n  # Accept for relay_from_hosts\n  accept\n    hosts = +relay_from_hosts\n\n  # Deny everything else (anti-relay)\n  deny\n    message = Relay not permitted<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Rate-limiting connections prevents DoS attacks. The localhost exception ensures local mail flows unrestricted. For advanced VPS security hardening beyond mail-specific ACLs, review our <a href=\"https:\/\/www.enginyring.com\/en\/blog\/the-ultimate-vps-security-guide-from-essential-hardening-to-elite-sysadmin-secrets\">Ultimate VPS Security Guide<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">HELO\/EHLO validation ACL<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Malware often sends malformed HELO strings. Configure strict validation in <code>\/etc\/exim4\/conf.d\/acl\/20_exim4-config_check_helo<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># HELO validation\nacl_check_helo:\n  # Accept local submissions\n  accept\n    hosts = :\n\n  # Deny obviously invalid HELO\n  deny\n    message = Invalid HELO hostname\n    condition = ${if match{$sender_helo_name}{^\\\\[|^\\\\.}{yes}{no}}\n\n  # Deny if HELO matches our hostname (likely forged)\n  deny\n    message = You are not $sender_helo_name\n    condition = ${if match_domain{$sender_helo_name}{$primary_hostname}}\n    !hosts = +relay_from_hosts\n\n  # Accept all others\n  accept<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These rules reject HELO strings starting with brackets or dots, and prevent impersonation. This blocks a significant percentage of botnet spam. Combine this with proper <a href=\"https:\/\/www.enginyring.com\/en\/blog\/a-beginners-guide-to-dns-security-why-it-matters-for-your-website\">DNS security best practices<\/a> for defense-in-depth.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">DATA ACL (content filtering)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Scan message content after the SMTP DATA command. Create <code>\/etc\/exim4\/conf.d\/acl\/40_exim4-config_check_data<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># DATA ACL - Content filtering\nacl_check_data:\n  # Deny oversized messages\n  deny\n    message = Message too large ($message_size bytes)\n    condition = ${if >{$message_size}{10M}{yes}{no}}\n\n  # Warn about potential data leaks\n  warn\n    condition = ${if match{$message_body}{@${primary_hostname}}{yes}{no}}\n    log_message = Potential internal address leak\n\n  # Accept message\n  accept<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Rejects messages over 10MB (adjust for your VPS resources) and logs potential internal address leaks\u2014common in misconfigured auto-responders. This content filtering is essential for maintaining <a href=\"https:\/\/www.enginyring.com\/en\/blog\/email-deliverability-guide-why-your-hosting-matters\">email deliverability<\/a> and protecting your domain reputation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SMTP authentication and TLS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Enable SMTPAUTH for client submission (port 587) and force TLS to protect credentials. Configure authentication backends and TLS certificates. For comprehensive VPS security beyond mail services, implement the hardening practices from our <a href=\"https:\/\/www.enginyring.com\/en\/blog\/how-to-secure-a-vanilla-vps-a-comprehensive-guide-for-linux-beginners\">VPS security guide<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Authentication backend<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create <code>\/etc\/exim4\/conf.d\/auth\/30_exim4-config_plain<\/code> for plaintext authentication (use only with TLS):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Plaintext authentication (TLS only)\nplain_server:\n  driver = plaintext\n  public_name = PLAIN\n  server_condition = ${if crypteq{$auth3}{${extract{1}{:}{${lookup{$auth2}lsearch{\/etc\/exim4\/passwd}{$value}}}}}{yes}{no}}\n  server_set_id = $auth2\n  server_prompts = :\n  .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS\n  server_advertise_condition = ${if eq{$tls_in_cipher}{}{no}{yes}}\n  .endif<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Store credentials in <code>\/etc\/exim4\/passwd<\/code> with format: <code>username:cryptedpassword<\/code>. Generate crypted passwords with: <code>mkpasswd -m sha-256<\/code>. For DMARC authentication alignment, ensure your authentication matches the policies outlined in our <a href=\"https:\/\/www.enginyring.com\/en\/blog\/what-is-dmarc-how-to-configure-it-and-why-a-poor-dmarc-record-can-spell-disaster\">DMARC configuration guide<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">TLS certificate configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Enable TLS in <code>\/etc\/exim4\/conf.d\/main\/03_exim4-config_tlsoptions<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># TLS configuration\nMAIN_TLS_ENABLE = yes\ntls_certificate = \/etc\/ssl\/certs\/exim.crt\ntls_privatekey = \/etc\/ssl\/private\/exim.key\ntls_advertise_hosts = *\n\n# Require TLS for authenticated connections\n.ifdef MAIN_TLS_CERTKEY\ntls_on_connect_ports = 465\n.endif<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Generate or obtain certificates. For production, use Let&#8217;s Encrypt: <code>certbot certonly --standalone -d mail.yourdomain.com<\/code> then symlink to Exim&#8217;s paths. Proper certificate management is part of broader <a href=\"https:\/\/www.enginyring.com\/en\/blog\/a-beginners-guide-to-dns-security-why-it-matters-for-your-website\">DNS security best practices<\/a> that every VPS administrator should implement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Port and daemon configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Configure Exim to listen on standard mail ports (25, 587, 465) with proper daemon options. Edit <code>\/etc\/default\/exim4<\/code> (Debian\/Ubuntu) or <code>\/etc\/sysconfig\/exim<\/code> (CentOS\/RHEL):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Listen on all interfaces, ports 25 and 587\nSMTPLISTENEROPTIONS='-oX 25:587:465 -oP \/run\/exim4\/exim.pid'\n\n# Queue runner interval (5 minutes)\nQUEUEINTERVAL='5m'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>-oX<\/code> option binds multiple ports. Port 25 for MTA-to-MTA delivery, 587 for authenticated submission with STARTTLS, 465 for implicit TLS. The queue runner ensures deferred mail retries every 5 minutes\u2014adjust based on your VPS resources and mail volume.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Logging and debugging<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Exim&#8217;s logging is verbose but precise. Configure log selectors to capture what matters without drowning in noise. Edit <code>\/etc\/exim4\/conf.d\/main\/90_exim4-config_log_selector<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Log configuration\nlog_selector = +all -subject -arguments\n\n# Main log file\nlog_file_path = \/var\/log\/exim4\/%slog\n\n# Set user\/group\nexim_user = Debian-exim\nexim_group = Debian-exim<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>log_selector = +all -subject -arguments<\/code> logs everything except message subjects (privacy) and command arguments (clutter). On busy VPS nodes, reduce to <code>+smtp_connection +smtp_incomplete_transaction +smtp_protocol_error +tls_cipher<\/code> to minimize I\/O. For automated log analysis and retention, consider implementing <a href=\"https:\/\/www.enginyring.com\/en\/blog\/automated-backup-strategies-for-vps-rsync-restic-and-off-site-storage\">automated backup strategies<\/a> that include log archival.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Real-time debugging<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use Exim&#8217;s debug mode to trace live SMTP sessions without restarting the daemon:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Test ACLs and routing without sending mail\nexim -bh 192.0.2.1\n\n# Show routing for a specific address\nexim -bt user@yourdomain.com\n\n# Show delivery transport\nexim -bv user@yourdomain.com\n\n# Run in foreground with debug output\nexim -bd -d+all<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>-bh<\/code> option simulates an SMTP connection from the specified IP, showing exactly which ACLs trigger. This is essential for testing firewall rules and relay restrictions on a VPS without affecting production traffic.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing and verification<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before declaring your Exim configuration production-ready, execute this verification checklist. Each test targets a common failure mode that breaks mail flow or exposes your VPS to abuse. If you encounter delivery issues, our guide on <a href=\"https:\/\/www.enginyring.com\/en\/blog\/how-to-fix-email-delivery-issues-when-emails-go-to-spam\">how to fix email delivery issues when emails go to spam<\/a> provides additional troubleshooting steps.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configuration syntax check<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Verify Exim configuration syntax\nexim -bV\n\n# Test configuration with specific file\nexim -C \/etc\/exim4\/exim4.conf.template -bV<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A successful verification returns version information and configuration file location. Any syntax errors show exact line numbers. Fix all errors before restarting the daemon.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Open relay test<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Test if VPS is an open relay (critical)\nexim -bh 203.0.113.1\nMAIL FROM:&lt;spammer@evil.com&gt;\nRCPT TO:&lt;victim@example.com&gt;\nDATA\nSubject: Relay test\n\nTest message\n.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If your ACLs are correct, the RCPT TO command should return &#8220;550 Relay not permitted.&#8221; If it accepts with 250, your VPS is an open relay and will be blacklisted within hours.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SMTPAUTH and TLS verification<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Test SMTPAUTH over TLS\nopenssl s_client -starttls smtp -connect your-vps-ip:587\nEHLO test\nAUTH PLAIN $(echo -ne '\\0user\\0password' | base64)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Successful authentication returns &#8220;235 Authentication succeeded.&#8221; Failed authentication returns &#8220;535 Incorrect authentication data.&#8221; Verify both outcomes to ensure your credentials file and AUTH configuration work correctly. For a complete self-hosted mail solution, see our guide on <a href=\"https:\/\/www.enginyring.com\/en\/blog\/take-back-your-privacy-the-complete-guide-to-migrating-from-gmail-to-a-self-hosted-mail-server\">migrating from Gmail to a self-hosted mail server<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Queue management verification<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># View mail queue\nexim -bp\n\n# Force queue run\nexim -qff\n\n# Remove frozen messages older than 7 days\nexiqgrep -z -o 604800 | xargs exim -Mrm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On a busy VPS, the queue can accumulate frozen messages from delivery failures. The last command automates cleanup, preventing disk space exhaustion.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting common issues<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Even correctly configured Exim installations encounter problems when deployed on diverse VPS environments. These solutions address the most frequent failures reported by sysadmins running Exim on ENGINYRING and similar infrastructure.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#8220;Relay access denied&#8221; for legitimate users<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Symptom:<\/strong> Local users cannot send mail; Exim logs show &#8220;relay denied&#8221; despite correct credentials.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Cause:<\/strong> The sender&#8217;s domain isn&#8217;t in <code>+local_domains<\/code>, or authentication isn&#8217;t being accepted properly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong> Verify domains are listed in <code>\/etc\/exim4\/update-exim4.conf.conf<\/code> under <code>dc_other_hostnames<\/code>. For multi-domain VPS setups, add all hosted domains to the local domains list. Ensure authenticated users have <code>accept authenticated = *<\/code> before relay deny rules.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">TLS handshake failures on port 587<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Symptom:<\/strong> Clients cannot STARTTLS; logs show &#8220;TLS error on connection from&#8230;&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Cause:<\/strong> Certificate permissions are wrong, or the certificate doesn&#8217;t match the hostname.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong> Ensure certificates are readable by the Exim user: <code>chown Debian-exim:Debian-exim \/etc\/ssl\/private\/exim.key && chmod 640 \/etc\/ssl\/private\/exim.key<\/code>. Verify certificate CN matches: <code>openssl x509 -in \/etc\/ssl\/certs\/exim.crt -noout -subject<\/code> should show your VPS hostname.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Queue freezes with &#8220;retry time not reached&#8221;<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Symptom:<\/strong> Messages remain frozen in queue for days despite destination being reachable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Cause:<\/strong> Exim&#8217;s retry logic has backed off to maximum interval and won&#8217;t attempt delivery again until the retry time expires.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong> Force immediate retry: <code>exim -qff<\/code>. To prevent recurrence, adjust retry rules in <code>\/etc\/exim4\/conf.d\/retry\/30_exim4-config<\/code>: <code>*  *  F,2h,15m; G,16h,1h,1.5; F,4d,6h<\/code> (retry every 15 minutes for 2 hours, then hourly for 16 hours, then every 6 hours for 4 days).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">High memory usage on small VPS<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Symptom:<\/strong> Exim processes consume excessive RAM on VPS plans with 1\u20132GB memory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Cause:<\/strong> Default Exim configuration spawns too many queue runners and delivery processes for low-memory environments.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong> Reduce process limits in main config: <code>queue_run_max = 2<\/code> (down from default 5) and <code>remote_max_parallel = 2<\/code> (down from 10). This trades throughput for resource efficiency, appropriate for small VPS deployments with limited concurrent connections.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SPF failures causing delivery rejections<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Symptom:<\/strong> Outbound mail rejected by major providers (Gmail, Outlook) with SPF failure errors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Cause:<\/strong> Your VPS IP isn&#8217;t in the SPF record for your domain, or you&#8217;re using a smarthost without SRS (Sender Rewriting Scheme).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong> Update your DNS SPF record: <code>v=spf1 ip4:your-vps-ip include:sendgrid.net ~all<\/code>. If relaying through a smarthost, consider enabling SRS. For complete SPF, DKIM, and DMARC implementation, refer to our <a href=\"https:\/\/www.enginyring.com\/en\/blog\/what-is-dmarc-how-to-configure-it-and-why-a-poor-dmarc-record-can-spell-disaster\">DMARC configuration guide<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why this ranks for sysadmin searches<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">System administrators search for &#8220;Exim configuration Linux VPS&#8221; repeatedly because Exim&#8217;s official documentation is exhaustive but lacks practical, production-ready VPS-specific examples. This guide fills that gap: it provides copy-paste configurations that work on real VPS infrastructure, includes exact ACLs that prevent relay abuse, and troubleshoots memory and performance issues specific to virtualized environments. Hosting providers like ENGINYRING need this content to reduce support tickets and position their infrastructure as sysadmin-friendly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From an SEO perspective, &#8220;Exim configuration&#8221; has moderate search volume but extremely high technical intent\u2014searchers are actively configuring mail servers and will bookmark comprehensive guides. The VPS-specific troubleshooting addresses real pain points that generic Exim tutorials ignore. Linking to <a href=\"https:\/\/www.enginyring.com\/en\/blog\/email-deliverability-guide-why-your-hosting-matters\">ENGINYRING&#8217;s email deliverability guide<\/a> creates a topical cluster that signals authority on mail infrastructure and helps sysadmins understand the full scope of running production email services on VPS platforms.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Configuring Exim as a production mail transport agent on a Linux VPS requires precision: one misconfigured ACL or transport rule can turn your server into an open relay or cause legitimate mail to vanish into queue purgatory. This playbook gives sysadmins a complete, production-ready Exim configuration for a VPS environment\u2014covering everything from basic installation to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2061,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[12594,12592,12600,12604,12599,12603,12598,12601,12597,12605,12602,12606,12596,12593,12595],"class_list":["post-2052","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-exim-acl-setup","tag-exim-configuration","tag-exim-debugging-vps","tag-exim-memory-usage-optimization","tag-exim-open-relay-prevention","tag-exim-production-configuration-vps","tag-exim-queue-management","tag-exim-router-transport-configuration","tag-exim-smarthost-relay","tag-exim-smtpauth-setup","tag-exim-spam-prevention-acl","tag-exim-spf-configuration","tag-exim-tls-configuration","tag-linux-vps-mail-server","tag-smtp-authentication-exim"],"_links":{"self":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2052"}],"version-history":[{"count":1,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2052\/revisions"}],"predecessor-version":[{"id":2054,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2052\/revisions\/2054"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/2061"}],"wp:attachment":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}