Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk11 min

How to Set Up a Mail Server With Exim, Dovecot and ClamAV on a VPS

A complete Debian/Ubuntu VPS walkthrough for building a mail stack with Exim4, Dovecot and ClamAV, including TLS, mailbox formats, documented ports, clamd permissions, validation tests and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can run a complete mailbox stack on a VPS by assigning one job to each service: Exim4 transfers SMTP mail, Dovecot lets users retrieve it over IMAP or POP3, and ClamAV scans message content for malware before delivery. The reliable setup order is hostname and DNS first, Exim and TLS second, Dovecot mailbox access third, and ClamAV integration last.

This guide uses the configuration workflow documented for Debian and Ubuntu systems. It covers split and single Exim configurations, authenticated SMTP, Dovecot mailbox formats and encrypted client ports, the Exim-to-clamd socket and ACL, and the tests that prove the local services are wired together. Local success does not by itself prove that major remote providers will accept your mail.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How the Exim, Dovecot and ClamAV stack fits together

Email passes through several roles rather than one all-purpose daemon. A mail user agent submits a message to a mail transfer agent (MTA). The MTA transfers it to another MTA or hands it to a delivery agent, and the recipient’s mail client retrieves the stored message through IMAP or POP3.

  • Exim4: the MTA. It accepts SMTP messages, authenticates senders when configured to do so, transfers mail, and delivers accepted messages to local mailboxes.
  • Dovecot: the mailbox access service. It presents the mailbox format selected on the server through IMAP and POP3, with encrypted IMAPS and POP3S options.
  • ClamAV: the malware scanner. Its clamd daemon receives messages from Exim through a Unix socket and reports whether content matches a malware signature.

Exim and Dovecot must agree on the mailbox layout. If Exim writes mbox files while Dovecot is configured for Maildir, authentication can succeed while users see empty or missing folders. Decide that layout before making delivery changes.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Prerequisites before installing packages

Prepare the VPS as a mail host before running the package setup. The exact package commands below assume a supported Debian or Ubuntu release and administrative access through sudo.

  • Choose a stable fully qualified domain name (FQDN) for the server, such as the host name assigned by your mail domain.
  • Configure the mail domain and its DNS records with the domain’s DNS provider.
  • Verify that the VPS provider permits the mail traffic your deployment needs. Some providers restrict outbound SMTP until an account review or request is completed.
  • Confirm that the server clock, package repositories and security updates work normally.
  • Have a trusted TLS certificate available for production. Its name must match the server FQDN.
  • Decide whether Exim will deliver directly to the internet or forward through a smarthost operated by another provider.
  • Choose mbox or Maildir and use the same choice in Exim and Dovecot.

Ubuntu’s Exim documentation specifically warns that the TLS “Server name” must be correct: it must match the system FQDN or TLS will not work correctly. Treat the hostname as a prerequisite, not as a cosmetic label entered after installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the configuration model first

Split versus single Exim configuration

During dpkg-reconfigure exim4-config, Exim asks whether to use a split configuration. Split mode stores modular files under /etc/exim4/conf.d; the single-template mode keeps the generated configuration in one template. Neither is universally correct. Split mode is easier to maintain when you need to add a TLS setting, authenticator or ACL without editing one large file. A single template can be simpler for a very small host where all settings are managed together.

Choice Where settings live Operational trade-off
Split configuration /etc/exim4/conf.d modular files Individual routers, transports, authenticators and ACLs are easier to locate and review; changes require regenerating the configuration.
Single template One generated/template configuration Fewer files to navigate, but unrelated settings are more tightly coupled and edits are harder to isolate.

mbox versus Maildir

Dovecot supports more than one mailbox layout. Select deliberately, then configure Exim’s local delivery to write to that same format. The important decision is consistency rather than a universal winner: changing formats later requires a mailbox migration, not just a service restart.

Layout How mail is organized What to check
mbox Messages are stored together in mailbox files. Exim’s delivery settings and Dovecot’s mailbox settings must point to the same files and permissions.
Maildir Messages are stored as individual files in mailbox directories. Directory ownership, paths and Dovecot’s Maildir setting must match Exim’s delivery destination.

Direct delivery versus a smarthost

Direct delivery gives the VPS control over SMTP transfer and queueing, but you are responsible for DNS correctness, reverse-DNS reputation, TLS identity and the receiving provider’s acceptance policies. A smarthost hands outbound transfer to another provider. That can reduce reputation-management work, but it introduces provider dependence and a separate authentication or relay configuration. The Ubuntu and Debian configuration mechanisms do not select one option for every deployment.

Prepare the VPS hostname and DNS

  1. Set the system FQDN. Configure the host name in the operating system and verify that local name resolution returns the intended fully qualified name.
  2. Make the certificate name and FQDN agree. The name entered as Exim’s TLS “Server name” and the name on the production certificate should be the same server identity.
  3. Publish DNS for the mail domain. Configure the records required by your delivery design, including the record that identifies where the domain receives mail. Confirm that the records resolve from outside the VPS before testing remote delivery.
  4. Check provider policy. Ask the VPS provider whether SMTP traffic is filtered or requires an unblock request. A perfectly configured Exim instance cannot deliver through a provider-level restriction.

Do not interpret a successful local connection as proof that DNS or reputation is correct. Those are separate, internet-facing dependencies.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install and configure Exim4

Install the MTA and select its initial mode

Install Exim4 from the distribution repositories, then run the interactive configuration:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
sudo apt update
sudo apt install exim4
sudo dpkg-reconfigure exim4-config

Use the reconfiguration prompts to identify the system FQDN, the mail domain and the delivery model you selected. Choose split configuration if you want modular files under /etc/exim4/conf.d; otherwise use the single template. Start the service after the initial configuration:

sudo service exim4 start

At this stage Exim can be installed without exposing authenticated submission to users. Add authentication and TLS before treating the host as a production mail server.

Enable authenticated SMTP safely

Exim can authenticate through PAM-backed saslauthd or an Exim password database. Both approaches protect credentials only when the SMTP session is protected by TLS. Ubuntu warns that these authentication methods use clear-text passwords unless TLS is enabled, so do not allow clients to submit credentials over an unencrypted connection.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose one authentication backend, configure its users and permissions according to the selected backend, and then enable TLS in Exim’s configuration. In a split configuration, the setting is commonly placed in the appropriate main-configuration file:

MAIN_TLS_ENABLE = yes

After editing Exim settings, regenerate the active configuration and restart the daemon:

sudo update-exim4.conf
sudo service exim4 restart

Use a self-signed certificate only for controlled testing. For production, install a certificate issued by a trusted authority and ensure its name matches the FQDN configured as Exim’s TLS server name. A certificate for a different host can make clients reject the connection even though Exim is listening.

Keep Exim changes reproducible

Record whether the host uses split or single configuration, which authentication backend is enabled, which mailbox format Exim delivers to and where the certificate is managed. Regenerate the configuration after every change rather than editing only a generated file that will be overwritten later. Restart Exim after regeneration so the running process uses the new settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Install and configure Dovecot

Install IMAP and POP3 services

Install the protocol services you intend to offer:

sudo apt install dovecot-imapd dovecot-pop3d

Review the main file and the included configuration directory:

/etc/dovecot/dovecot.conf
/etc/dovecot/conf.d/

Select mbox or Maildir in Dovecot and make the corresponding Exim delivery choice. Check that the operating-system users who own the mailboxes can be read by Dovecot and written by Exim. Restart Dovecot after changing its configuration:

sudo service dovecot restart

Use encrypted client ports in production

Ubuntu Server documentation lists these Dovecot client ports:

Service Port Encryption Typical use
IMAP 143 Plain protocol port; encryption depends on the TLS mode negotiated by the service. IMAP clients where the server policy explicitly requires TLS negotiation.
IMAPS 993 SSL/TLS from connection start Encrypted IMAP client access.
POP3 110 Plain protocol port; encryption depends on the TLS mode negotiated by the service. POP3 clients where the server policy explicitly requires TLS negotiation.
POP3S 995 SSL/TLS from connection start Encrypted POP3 client access.

Ubuntu states: “IMAPS and POP3S are more secure because they use SSL encryption to connect.” Configure Dovecot’s TLS settings in the SSL configuration file, typically 10-ssl.conf, and use the trusted production certificate rather than a self-signed certificate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Open only the client and server ports required by your design in the VPS firewall. The documented Dovecot ports are 143, 993, 110 and 995; Exim’s SMTP listeners and any authenticated-submission listener must also be allowed or restricted according to your provider and security policy.

Install ClamAV and update its signatures

Install the scanner, its daemon and the signature updater:

sudo apt install clamav clamav-daemon clamav-freshclam

The Debian documentation identifies clamav-freshclam as the database updater and clamav-daemon as the scanning daemon. Allow the updater to obtain current signatures, then make sure the daemon is running before connecting Exim to it. A scanner that is installed but not updating or not running will not provide the protection you expect.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Connect Exim to clamd

Point Exim at the ClamAV socket

In a split Exim configuration, define the scanner socket:

av_scanner = clamd:/var/run/clamav/clamd.ctl

The path must match the socket created by your distribution’s running clamd service. Check the actual socket path on the VPS instead of assuming a path from another release.

Reject malware in a DATA ACL

Scanning at the SMTP DATA stage lets Exim reject a message before accepting it for delivery. Add a DATA ACL rule that rejects a positive malware result:

deny
  malware = *
  message = This message contains malware ($malware_name)

Keep the rule in the ACL section used for DATA processing, regenerate the Exim configuration and restart Exim. The exact surrounding ACL file differs between split and single configurations, which is why documenting the chosen mode matters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix socket and spool permissions

The ClamAV process must be able to access the Exim spool and the Exim process must be able to reach the clamd socket. Add the clamav user to the Debian-exim group using the distribution’s group-management command, then restart the scanner daemon:

sudo adduser clamav Debian-exim
sudo service clamav-daemon restart

If your release uses different service names or group ownership, use the names shown by the installed packages. Do not make the socket world-writable as a shortcut; correct group membership and ownership are safer ways to resolve access errors.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Restart in a predictable order

After configuration changes, use an order that exposes dependencies quickly:

  1. Update ClamAV signatures and restart clamav-daemon.
  2. Restart Dovecot after validating its mailbox and TLS settings.
  3. Run sudo update-exim4.conf to regenerate Exim’s configuration.
  4. Restart Exim with sudo service exim4 restart.
  5. Check service logs and perform local protocol tests before attempting an internet delivery.

Restarting Exim before clamd is available can produce socket or scanner errors. Restarting only one service after changing a shared mailbox layout can leave the two daemons disagreeing about where mail resides.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate each layer locally

Check Dovecot’s POP3 banner

Ubuntu’s Dovecot guide demonstrates a simple local POP3 check. Connect to the POP3 port:

telnet localhost 110

A working Dovecot POP3 service responds with a banner beginning +OK Dovecot ready. This confirms that the local POP3 daemon is listening and responding; it does not test TLS, remote firewall rules or a user’s password.

Check encrypted client access

Configure a test mail client for IMAPS on 993 or POP3S on 995 with the production certificate and a test mailbox. Confirm that the certificate name matches the server FQDN and that the client can authenticate without sending credentials over an unencrypted session.

Test the Exim-to-ClamAV path

Use the standard EICAR test virus, not live malware, in a controlled test message. The Exim/ClamAV integration guidance expects the server to reject the message immediately when the DATA ACL detects it. A rejection demonstrates that Exim can reach clamd, clamd can scan the message and the ACL policy is active.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Also send a harmless message between two local test accounts. Confirm that Exim accepts it, writes it in the selected mbox or Maildir format and that Dovecot exposes it through the corresponding protocol.

Troubleshoot by symptom

Symptom Likely cause What to inspect
TLS warning or certificate rejection The Exim “Server name” or Dovecot certificate name does not match the FQDN, or a self-signed certificate is being used. System FQDN, certificate subject/SAN and the TLS settings in Exim and Dovecot.
SMTP authentication fails The selected PAM/saslauthd or Exim password database is incomplete, or credentials were attempted without TLS. Authentication backend configuration, service permissions and whether the client negotiated TLS first.
Mailbox login works but no messages appear Exim and Dovecot use different mailbox formats or paths. Exim’s local delivery transport, Dovecot’s mbox/Maildir setting and mailbox ownership.
ClamAV scanner error or timeout clamd is stopped, the socket path is wrong or group permissions block access. /var/run/clamav/clamd.ctl, daemon status, socket ownership and Debian-exim group membership.
EICAR message is accepted The DATA ACL is not active, the scanner is unreachable or the wrong Exim configuration was regenerated. The generated Exim configuration, av_scanner line, ACL order and clamd logs.
Local delivery works but remote providers reject mail Internet-facing DNS, reverse-DNS reputation, SPF/DKIM/DMARC policy or provider restrictions are unresolved. DNS and provider requirements separately from local service health.

Security and maintenance checklist

  • Use a trusted certificate whose name matches the FQDN in production.
  • Require TLS before allowing authenticated SMTP credentials to be transmitted.
  • Offer encrypted IMAPS or POP3S to clients and restrict unencrypted protocol access according to your policy.
  • Keep ClamAV signatures current through clamav-freshclam.
  • Monitor the clamd socket, Exim queue and Dovecot authentication failures.
  • Back up mailbox data and the configuration files that define Exim, Dovecot and ClamAV integration.
  • Apply operating-system security updates and review firewall rules after package or network changes.
  • Document every generated-configuration step so a future edit is not lost on the next package update.

What these tests do—and do not—prove

A successful POP3 banner check proves that Dovecot answers locally. A successful EICAR rejection proves that Exim can invoke clamd and apply the malware ACL. A local message appearing in a test mailbox proves that Exim and Dovecot agree on the mailbox layout. None of those checks establishes global deliverability, reverse-DNS reputation, SPF, DKIM or DMARC correctness, or acceptance by a particular remote provider.

Evaluate those internet-facing properties separately after the local stack is stable. If a provider blocks SMTP, no change to a Dovecot port or ClamAV ACL will remove that upstream restriction.

Recommended build sequence

  1. Set the VPS FQDN, mail domain, DNS and provider permissions.
  2. Install Exim4 and complete dpkg-reconfigure exim4-config.
  3. Choose split or single configuration and select mbox or Maildir consistently.
  4. Install a trusted certificate, enable Exim TLS and configure authenticated SMTP.
  5. Install Dovecot, select the same mailbox format and configure TLS client access.
  6. Install ClamAV, clamav-daemon and clamav-freshclam.
  7. Set the clamd socket, add the DATA ACL, correct group permissions and restart the scanner.
  8. Regenerate and restart Exim, then test local POP3, mailbox delivery and EICAR rejection.
  9. Only after those checks pass, investigate remote deliverability and reputation.

Following that order keeps identity, transport, mailbox access and malware scanning testable as separate layers. It also makes failures diagnosable: hostname and certificate problems remain distinct from mailbox-format mismatches, and both remain distinct from provider-level delivery decisions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.