You want to send email to a process. You want that process to be implemented by a perl script.

This amounts to needing to tell your local mail delivery system that instead of sending mail for a particular address to a user's mailbox it should instead be delivered to a process.

"Being delivered to a process" means different things. You could, for example, have the mail delivered normally to a mailbox and go through the mailbox with a perl module. But thats fugly. "We don't want to give you that".

If you've got a POP or IMAP server you could deliver the mail to a mailbox and then slurp it into a perl script using the Net::POP3 or similar module. Less ugly, but still too ugly to live. "But we don't want to give you that".

If you were using sendmail as your local mail delivery system, it honours something called '.forward' files. (This is UNIX, right?) I know you aren't using sendmail, but stay with me here.

You create a unix user id corresponding to the script you want to run and create a file called '.forward' in that user's home directory. The original purpose of such a file was so you could put another email address in here and have all your mail forwarded to that address.

Instead of forwarding to another email address you can instead put in the name of an executable command, for example a perl script.

The email gets handed to the process on standard input. Typically in the form of "headers + blank line + body". There are perl modules to help you grok these things.

The '.forward' concept applies to sendmail, but because of sendmail's previous ubiquity, is also supported by many other mail systems. I don't know if qmail is one of these but I would hazard a guess that it will either support this as is (i.e. it will 'just work') or grepping the qmail docs for '.forward' will help you.

Of course, there are probably better ways of doing this depending on a) how much access you have to the local system (above idea does not require root) and b) how much you want to read the docs.

For example, sendmail also supports configurable local delivery agents, so cool tools like procmail can be run more efficiently and securely by the mailer.

Basically its a qmail issue if you are using qmail. It will have some mechanism for delivery to a process and the above posted comments about reading standard input will then apply.

Have fun


In reply to Re: give perl an email by jbert
in thread give perl an email by skazat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.