MIMEDefang Releases Version 2.85

Quick Start for CentOS 7 / CentOS Stream
Aug 27, 2021

MIMEDefang is a highly flexible and configurable email filter program that was originally written by Roaring Penguin and Dianne F. Skoll. It is maintained by the McGrail Foundation. With the release of MIMEDefang version 2.85 this week, we wanted to produce a quick start. More can be found out about specifics of MIMEDefang on our Projects page.

MIMEDefang is part of Extra Packages for Enterprise Linux (EPEL) on CentOS/Red Hat and version 2.85 should be available soon. If you would like to experiment with MIMEDefang, the following steps should be helpful

  • Step 1: Install a minimal version of CentOS 7 or CentOS-Stream

  • Step 2: Install EPEL:
    • yum install epel-release

  • Step 3: Refresh the repositories:
    • yum repolist

  • Step 4: Remove Postfix and use Sendmail:
    • yum remove postfix

    • NOTE: MIMEDefang works with Postfix too but requires sendmail-milter for the Sendmail Milter Library. If you'd like to use Postfix please go to steap 8a. Otherwise, remove Postfix and install Sendmail.

  • Step 5: Install Sendmail:
    • yum install sendmail sendmail-milter sendmail-cf

  • Step 6: Install MIMEDefang:
    • yum install mimedefang

  • Step 7: Enable MIMEDefang as a milter with Sendmail:
    • echo "INPUT_MAIL_FILTER(\`mimedefang',
      \`S=unix:/var/spool/MIMEDefang/mimedefang.sock, F=T, T=C:15m;S:4m;R:4m;E:10m')" >> /etc/mail/sendmail.mc

    • NOTE: Cut and paste this exactly. The quotes, ticks, and backticks are important and it’s all one command line.

  • Step 8: Compile the sendmail configuration files:
    • make -C /etc/mail

    • Step 8a: if you want to use Postfix instead you should run the following commands:
      • postconf -e “smtpd_milters = unix:/var/spool/MIMEDefang/mimedefang.sock”
        postconf -e “non_smtpd_milters = $smtpd_milters”

  • Step 9: Change a few default settings in /etc/sysconfig/mimedefang

  • Step 10: Enable and Start the MIMEDefang Service:
    • systemctl enable mimedefang

    • systemctl start mimedefang

  • Step 11: Enable and Start the Sendmail Service:
    • systemctl enable sendmail

    • systemctl restart sendmail

    • Step 11a: Enable and Start the Postfix Service:
      • systemctl enable postfix

      • systemctl restart postfix

  • Step 12: Download the KAM Demo filter
    • NOTE: This demo filter does not change anything in an email, it just provides debug statements so you can watch an email as it goes through the MIMEDefang processing.

  • Step 13: Install the mimedefang-filter.kamdemo replacing /etc/mail/mimedefang-filter

  • Step 14: Test that the filter is syntactically correct:
    • mimedefang.pl -test

  • Step 15: Read the new filter:
    • md-mx-ctrl reread

    • NOTE: If you end up with an SELinux error, try confirming with
      setenforce 0

  • Step 16: Monitor the mail log:
    • tail -f /var/log/maillog

  • Step 17: Inject an email manually and watch the mail log:
    • telnet localhost 25
      helo test.com
      mail from: kevin@test.com
      rcpt to: root
      Subject: This is a test
      Date: jasjdkasjdksajd

      This is a message
    • NOTE: That last line has just a period on it. And if you need,
      yum install telnet

We hope this is helpful and please reach out on the mailing list for more help on using MIMEDefang! Interested in a CentOS8 Quickstart or how to use MIMEDefang with Postfix? Let us know at the Contact Us!