I'm actually running quite a few scripts this way, and in fact have been writing one this week that handles quite a few neat things in an incoming email, and responds with an attachment to the sender.

A few things:

  1. Have you run newaliases after updating the /etc/mail/aliases file?
  2. Are you sure the script is valid, reachable, in the mail user's path, permissions are correct, and it's not misspelled?
  3. Can you run the script at the shell as the mail user interactively? (su - mail; perl /path/to/your/file.pl)
  4. Remember that many MDAs will run sendmail/procmail/etc. under a wrapper such as smrsh, so you have to be careful about the environment, and make sure to set paths and such ($ENV{'HOME'} = '/var/mail'; for example).
  5. The proper syntax for /etc/mail/aliases is as follows:
    udb: "|/path/to/my/file.pl" # ^ this is a tab, not spaces

Also, what are the errors the script returns? Have you tried a simple script that opens a file in /tmp, writes out to it and then closes the file, to see if any script is being executed?


In reply to Re: Invoking Perl script from an email by hacker
in thread Invoking Perl script from an email by stew

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.