[Mimedefang] tagging mail sent to aliases

John Nemeth jnemeth at victoria.tc.ca
Fri Jan 14 06:27:31 EST 2005


On Jun 2,  4:47pm, Jan Pieter Cornet wrote:
} 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.

     Yeah, I did simply things a bit.  The complete process is:

- if DelayLA is greater then 0 and current LA is greater then DelayLA
  then sleep one second
- if BadRcptThrottle is greater then 0 and the number of bad receipients
  is greater then or equal to BadRcptThrottle then sleep one second
- if the client has not sent a MAIL command then error
- if MaxRcptPerMsg is greater then 0 and the number of recipients is
  greater then or equal to MaxRcptPerMsg then error
- skip over "TO"
- parse the address
- if there was no address then error
- put the address into the macros rcpt_mailer, rcpt_host, and rcpt_addr
- parse ESMTP arguments
- if any problems then error
- call check_rcpt ruleset
- call milter_envrcpt
- clear macros
- call the recipient() function which does things like checking for
  direct mailing to restricted mailers, checking for forwarding to programs
  when the user has an invalid shell, checking for aliases, checking for a
  valid local user, etc.
- if no errors then send recipient okay to client else send error
- if any errors increment the number of bad recipients
- done

This was gleaned by reading the source code for Sendmail 8.13.2.  I'm
not totally sure where virtusertable fits into this.

} 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.

     Some of these are caught by the call to check_rcpt

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

     Okay, these must happen in check_rcpt.  However, since these are
done before the milter is called, it can still reject them.

} 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>

     I am very much aware of this.  I've actually patched my copy of
sendmail to call recipient() before calling milters.  Without that, due
to the use of stream_by_recipient() I get about 100 double bounce
messages per hour landing in my INBOX.  I haven't had any problems with
my patch, but I won't guarantee there are no problems either.

} 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

     This is an interesting idea.  However, I have 1,508 accounts and
952 aliases (some of which expand to multiple users).  Also, most
maintenace of the system is scripted.  It would be quite a bit of work
to implement this suggestion.

}-- End of excerpt from Jan Pieter Cornet



More information about the MIMEDefang mailing list