BUU has asked for the wisdom of the Perl Monks concerning the following question:

My question is probably somewhat off topic as it doesn't deal specifically with the vageries of perl syntax or anything of that nature. It does however relate to my love of perl and my obsession to use it to do everything I can possibly do. So heres my question:

Is there any mail server (SMTP) that allows me interface directly with it and even replace parts of it, using perl? An example of what I'm looking for is the apache server, which handles regular files just fine but then you can add mod_perl and rewrite portions of it in perl to do magic and still keep the highly optimzed/bugfree/etc portion doing everything it was designed for and does best. The reason I'm asking this is I'm working on some webhosting issues that involve multiple email accounts for one user and stuff like that. I'm sure theres possibly a way to do what I want natively in the server, such as sendmail.. but that would require learning the sendmail syntax and the sheer idea is enough to make me break down and gibber. But I don't wish to reinvent the wheel by writing my own SMTP server in perl or anything like that. So I'm attempting to leverage two things namely my knowledge of perl and the functionality of a good SMTP server.

Replies are listed 'Best First'.
Re: Sendmail + perl?
by esh (Pilgrim) on Aug 27, 2003 at 08:15 UTC

    I use Postfix and configure it to deliver email with no other logical destination to a .forward Perl script which is written with Mail::Audit so that I can do fancy logic about post-processing and redirection to final destinations.

    You might even find that you don't need to use Perl, but that Postfix directly supports the type of multiple accounts per user you want to provide.

    Update: Use Email::Filter instead of Mail::Audit per the author's documentation.

    -- Eric Hammond

      There is a Mail::Filter module on CPAN too. How those two Mail::Audit and Mail::Filter compare?

        Mail::Filter doesn't do at all the same thing, but since you made me go look, I see that Mail::Audit has been replaced by Email::Filter. Both are written by the same author (Simon Cozens) and Mail::Audit documentation has a comment that Email::Filter should be used instead.

        Looks like I have a conversion project to add to my todo list.

        -- Eric Hammond

Re: Sendmail + perl?
by esh (Pilgrim) on Aug 27, 2003 at 08:11 UTC
Re: Sendmail + perl?
by Abigail-II (Bishop) on Aug 27, 2003 at 08:42 UTC
    I don't know what exactly you want to do (if it's just users having more than one email address, that's trivial in sendmail, just set up an alias), but sendmail isn't modular in the sense that you can replace certain parts of it with code you wrote. And I don't know any MTA that does.

    However, if it's just some kind of post-processing (which would include any redirection) of incoming email, that's fairly trivial with MTAs like sendmail, qmail or postfix. But that's not a Perl issue anymore, and you're better off consulting the various manual pages.

    Abigail

Re: Sendmail + perl?
by ritontor (Acolyte) on Aug 27, 2003 at 08:08 UTC
    Postfix uses a regexp engine for mail filtering, although i'm not certain it's perl regexp...
Re: Sendmail + perl?
by shenme (Priest) on Aug 27, 2003 at 16:09 UTC
    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.
Re: Sendmail + perl?
by perrin (Chancellor) on Aug 27, 2003 at 21:44 UTC
    ActiveState's PureMessage is exactly what you descibed: a Perl interface to Sendmail. It is a commercial product though, so if you were looking for an open source solution, this is not it.