[Mimedefang] tagging mail sent to aliases

Jan Pieter Cornet johnpc at xs4all.nl
Mon Jan 10 16:11:21 EST 2005


On Thu, Jan 06, 2005 at 12:11:52AM -0800, John Nemeth wrote:
>      Can't do this since mail is sent to milters before sendmail does
> any processing, including checking to see if the receipient is valid.

This is not entirely correct.

What sendmail does, is split a recipient address into a (user,host,mailer)
triple, using its standard .cf file macro language, BEFORE calling into
any milter.

Therefore, syntax errors and things like illegal relay attempts are catched
by sendmail before milter (or MIMEDefang) sees them.

Also, if you happen to use features like a genericstable or a virtusertable,
then those lookups happen before milter calls.

If the result is the "error" mailer (usually because the sendmail ruleset
has "$#error" in it, or maybe because your virtusertable contains an
error:bla entry), then milter isn't called either.

Note, I'm talking about SMTP-level "RCPT To:" time, which is
filter_recipient in mimedefang (xxfi_envrcpt in milter).

Only after milter returns, are actual mailer checks performed, like
/etc/aliases lookups, or matches against the local user database, 
if requested by the mailer flags.

This is why you will normally see a mimedefang call for:
>>> RCPT To:<invaliduser at yourdomain.example.org>

But no mimedefang call for:
>>> RCPT To:<somewhere at else.not.yours.example.com>

Hope this helps... somewhat.

What you might do is ditch the aliases entirely, put all local users
mapping to themselves in a virtusertable, and then put in a catchall
entry

@yourdomain.example.org		%1 at fixspelling.yourdomain.example.org

And put in a mailertable entry:

fixspelling.yourdomain.example.org	fixspel:%1

.. then define a dummy "fixspel" mailer, catch that mailer within
mimedefang, and use perl's String::Approx module to catch spelling
mistakes, and either rewrite to the correct user, or return
a "user too badly misspelled" error (and set your custom header at the
same time! But you'll have to roll your own spam_assassin_* routines,
can't use the default mimedefang ones :)

(Note: untested! :)

-- 
#!perl -wpl # mmfppfmpmmpp mmpffm <pmmppfmfpppppfmmmf at fpffmm4mmmpmfpmf.ppppmf>
$p=3-2*/[^\W\dmpf_]/i;s.[a-z]{$p}.vec($f=join('',$p-1?chr(sub{$_[0]*9+$_[1]*3+
$_[2]}->(map{/p|f/i+/f/i}split//,$&)+97):qw(m p f)[map{((ord$&)%32-1)/$_%3}(9,
3,1)]),5,1)='`'lt$&;$f.eig;                                # Jan-Pieter Cornet



More information about the MIMEDefang mailing list