Bobcares

How to Set Up Sendmail with ClamAV and MILTER Support

by | Jan 17, 2025

Learn how to set up Sendmail with ClamAV and MILTER Support. Our Sendmail Support team is here to help you with your questions and concerns.

How to Set Up Sendmail with ClamAV and MILTER Support

How to Set Up Sendmail with ClamAV and MILTER SupportDid you know that Sendmail integrates seamlessly with MILTER and ClamAV to enhance email security and filtering capabilities?

Our Experts have compiled this step-by-step guide to help you start configuring this setup.

 

Step 1: Check for MILTER Support

Sendmail requires MILTER support to function with filters. To verify if MILTER is enabled, run:

$ sendmail -d0 < /dev/null | grep MILTER

If MILTER appears in the output, proceed to the next step. For systems like RedHat Linux, ensure the `sendmail` and `sendmail-devel` packages are installed:

# yum install sendmail sendmail-devel

If using Sendmail 8.12, add the following entries to `site.config.m4` and rebuild:


APPENDDEF(`confENVDEF', `-DMILTER')
dnl APPENDDEF(`conf_libmilter_ENVDEF', `-D_FFR_MILTER_ROOT_UNSAFE')

To rebuild Sendmail:

$ sh Build -c -f /etc/mail/site.config.m4

Then, ensure the `libmilter` library is installed:

$ locate libmilter | grep /usr/local

If not, install it from the Sendmail source directory:


$ cd libmilter
$ sh Build install

Step 2: Configure ClamAV with MILTER Support

Now, we have to make sure ClamAV is configured with MILTER support. From the ClamAV source directory:

$ ./configure --enable-milter
$ make && make install

Then, update `clamd.conf` with critical options:


LocalSocket /var/run/clamav.sock
LogSyslog
FixStaleSocket
StreamSaveToDisk
StreamMaxLength 10M
User clamav
ScanMail
ScanArchive
ArchiveMaxFileSize 10M

Next, start the ClamAV daemon:

$ sudo /usr/local/sbin/clamd

Step 3: Launch ClamAV-MILTER

Now, start the ClamAV-MILTER service with the appropriate options:


$ sudo /usr/local/sbin/clamav-milter --max-children=2 -olb \
local:/var/run/clamav-milter.sock

For testing, use `–max-children=2`. Increase this value for production use.

Then, create a quarantine directory:


# mkdir /var/mail/quarantine/
# chown clamav:clamav /var/mail/quarantine/
# chmod 600 /var/mail/quarantine/

Step 4: Configure Sendmail for ClamAV-MILTER

Next, update the `sendmail.mc` file to enable virus scanning:


INPUT_MAIL_FILTER(`clamav-milter', `S=local:/var/run/clamav-milter.sock, F=T, T=S:4m;R:4m;E:10m')
define(`confINPUT_MAIL_FILTERS', `clamav-milter')

Then, rebuild the `sendmail.cf` configuration file:


# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# service sendmail reload

Step 5: Test the Configuration

At this point, send a test email with an EICAR test string:

# echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' | sendmail -v abc@domain.com

Also, verify the message is quarantined or appropriately flagged by ClamAV.

Additional Notes

  • Use `T=S:4m;R:4m` to define timeouts for sending and receiving to/from the filter.
  • Also, update ClamAV logs with `LogFile /var/log/clam/clamd.log`.
  • Then, increase `–max-children` and other parameters for production systems.

This configuration ensures the Sendmail setup integrates effectively with ClamAV and MILTER, providing robust email filtering and security.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In brief, our Support Experts demonstrated how to set up Sendmail with ClamAV and MILTER Support.

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF