CINXE.COM
MikeL's FreeBSD howto - Milter
<html><head> <title>MikeL's FreeBSD howto - Milter</title> </head><body> <center><font size="+2"><b>MikeL's FreeBSD howto - Milter</b></font></center> <hr> [20200512]<br> I no longer recommend this - just use <a href="spamass.html">SpamAssassin</a>.<br> <hr> If you get anywhere near as much spam junk as I get, you <em>need</em> to use <a href="http://www.milter.org/">Milter</a>! Here's some details to get it going...<p> The following example is for <a href="http://www.benzedrine.cx/milter-regex.html">milter-regex</a>, a "port" in FreeBSD which I use and recommend. Don't bother asking me about any others, as this is the only one I've ever used...<p> Build/install: <ul> <li><code>cd /usr/ports/mail/milter-regex/</code></li> <p> <li><code>su</code> (and password)</li></li> <p> <li><code>make</code></li> <p> <li><code>make install</code></li> </ul> milter-regex installation doc is in it's man page (man 8 milter-regex)<p> On your server, you need to make the following config changes:<br> <ul> <li>(In modern FreeBSD, the default is for sendmail to have already been compiled with milter enabled. If the package you're using gives you instructions on doing this, you may simply skip this step on FreeBSD.)</li> <p> <li>You should be using M4 for sendmail config. If not, this is the time to make the change. Trust me, it's worth it.</li> <p> <li>In your .mc file, you'll add something like the following:<br> <code>INPUT_MAIL_FILTER(`milter-regex', `S=unix:/var/spool/milter-regex, T=S:30s;R:2m')</code><br> This example is for milter-regex. The specific incantation for the package you've chosen will be in it's documentation.<br> <font size="-1">A note on .mc files: Anything following a "dnl" is a comment. You do <em>not</em> need a trailing "dnl" on .mc file lines, regardless of how many examples of this you see on the web. You can test this yourself, by 'make'ing your config file, then removing all trailing "dnl"s, remaking the file and 'diff'ing them.</font> </li> <p> <li>As described in the manpage, modify your <code>/etc/rc.conf</code> adding:<br> <code>milter_regex="YES"</code><br> <code>milter_flags="-c /etc/mail/milter-regex.conf"</code><br></li> <p> <li>As described in the manpage, modify (or create if non-existant) your <code>/etc/rc.local</code> adding:<br> <code>if [ X"${milter_regex}" == X"YES" -a \<br> -x /usr/local/libexec/milter-regex ]; then<br> echo -n ' milter-regex'<br> /usr/local/libexec/milter-regex ${milter_flags}<br> fi </code><br> <em>Note!</em> I've added the "milter_flags" var, and am specifying a config file location other than the default.</li> <p> <li>Build yourself a milter-regex file. For testing purposes I whipped up the following, in memorium of the Internet's earliest (to have notoriety) spammer:<br> <code>#<br> # milter-regex file vintners.net MikeL 12-Nov-2003<br> #<br> <br> reject Rejected, spamvertised website "cyberpromo.com"<br> body ,http://[^/]*cyberpromo\.com/,i<br> </code></li> </ul> Testing your config:<br> <ul> <li>Start milter-regex (I'd recommend following the Troubleshooting steps below).</li> <p> <li>Send yourself an email containing an offending pattern.<br> Simply going to the commandline and invoking 'sendmail -t' and slapping out that message will do just fine.<br> <code> brix# sendmail -t<br> To: <your-email-addr><br> From: <your-email-addr><br> Subject: testing<br> <blank line><br> http://www.cyberpromo.com/<br> <hit Ctrl-D><br> brix#</code> </li> <p> <li>Check your mailbox for bounce message or other appropriate behaviour depending upon your rules.</li> <p> <li>Check your logs (<code>/var/log/maillog</code>) -- search for <code>reject=</code>. If it's working, you'll see "reject=" entries corresponding to the milter rules you've set up. In my sample above, "reject=554" will do nicely.</li> </ul> Troubleshooting:<br> <ul> <li>As described in the manpage, start milter-regex from a commandline with the '-d' switch. It will then say:<br> <code>started<br> calling smfi_main()</code><br> and then just sit there until an email arrives. You'll know it when a mail arrives as it will display what's happening, starting with:<br> <code>cb_connect(...)<br> loading configuration file</code><br> etc. </li> <p> <li>(Just a note -- milter-regex <em>appears</em> to check for a config file change each time it gets an email to process. If there's been a change, it will then slurp it in.)</li> <p> <li>If you don't see immediate activity upon sending yourself the test email, you probably (one or more of): <ul> <li>Forgot to '<code>make</code>' after changing the .mc file in <code>/etc/mail/</code></li> <li>Forgot to copy generated .cf file into '<code>sendmail.cf</code>'</li> <li>restart sendmail</li> </ul></li> <p> <li>Hit Ctrl-C to quit interactive mode. Give it a <nobr>moment --</nobr> After a few seconds, app will quit saying "<code>terminating gracefully</code>".</li> </ul> <hr> <!-- begin mikel_cpyrht.htin --> <CENTER><font size="-1">Copyright © 1995-2024 <a href="http://vintners.net/~mikel/mikel.html"> Mike Lempriere</a></font> (running on host bayanus)</font> </CENTER> <!-- end mikel_cpyrht.htin --> </BODY></HTML>