in reply to Sendmail + perl?
It is possible for sendmail to call Perl code at various points in its processing - and that's about as much as I know. Use Google and search "milter api sendmail" for some links. The module Sendmail::Milter is a little old but presumably still good for use.