Operating System - HP-UX
1838226 Members
3850 Online
110125 Solutions
New Discussion

Re: Creating a script called from a user's .forward file

 
SOLVED
Go to solution
Fred G. Claypool, Jr.
Frequent Advisor

Creating a script called from a user's .forward file

Hi there...

For a while now, I've read that a user's .forward file can be used to somehow forward messages received to a PROGRAM instead of to a human recipient somewhere. I'd appreciate any pointers as to where I can find additional information regarding this process.

We're an SAP R/3 shop, and our central admin user (prdadm) gets inundated with returned mail messages resulting from our customers inputting bogus email addresses for themselves. Right now, all of this "bad email" gets forwarded to my Microsoft Outlook mailbox. But I'd really like to be able to have HP-UX analyze the bad email (an attachment really) and forward the messages to the appropriate service individuals.

Like I said, I appreciate any advice you may have. Thanks.
Experience gained while correcting a previous mistake is the best teacher imaginable!
6 REPLIES 6
S.K. Chan
Honored Contributor
Solution

Re: Creating a script called from a user's .forward file

Sounds like a job for procmail. That's the tool we used to filter out emails, save them into dirs, delete unwanted emails and much more.
http://hpux.connect.org.uk/hppd/hpux/Networking/Mail/procmail-3.22/
All my procmail rules are defined in .procmailrc and my .forward file looks like this ..
"|exec /usr/local/bin/procmail"
Christopher Caldwell
Honored Contributor

Re: Creating a script called from a user's .forward file

Things that appear on the "right hand side" of an address [from sendmail's perspective] can be a mailbox, a file, a list of addresses, a program.

The reference I use[d] is called Administering ARPA Services [manual number B1014-90008] -- copyright 1992 - believe it or not everything still applies.

You can add anything that appears on the "right hand side" to the aliases table (/etc/mail/aliases) or you can allow the user to invoke [most of] the same functionality from a .forward file in their home directory.


Here's an example of invoking a procmail recipe directly from the aliases table:

myinfoproc : | "/usr/local/bin/procmail -m /var/opt/procmail/.myprocmailrc"

You'd invoke it by sending mail to myinfoproc@mydomain.com


Here's an example of invoking a procmail recipe from a .forward file:

$cat $HOME/.forward
| "/usr/local/bin/procmail #testuser"


procmail excels at mail handling. You can download a copy from http://www.procmail.org/
Versions are also available from the porting archive.


Chris Wong
Trusted Contributor

Re: Creating a script called from a user's .forward file

Here's some examples from the sendmail book:

\user, "|/usr/ucb/vacation user"

"|exec /usr/local/bin/procmail #user"

"| /usr/local/lib/mh/slocal -user user"


- Chris

Fred G. Claypool, Jr.
Frequent Advisor

Re: Creating a script called from a user's .forward file

Thank you all very much for your responses. You've certainly put me on the right track for getting this job done. Thanks again.
Experience gained while correcting a previous mistake is the best teacher imaginable!
Joseph Fisher
Occasional Contributor

Re: Creating a script called from a user's .forward file

My .forward file is configured exactly like the examples in this forum.

\mqm,"|/u01/app/home/mqm/Mail_Parser"

The "mqm" user is receiving messages, but the incoming messages are NOT getting to the .forward file...

What in sendmail, causes a new message to be routed to the users $HOME directory, and subsequently the .forward file?

TIA

Joe F...
Fred G. Claypool, Jr.
Frequent Advisor

Re: Creating a script called from a user's .forward file

Joseph,

Make sure that the user's .forward file is set NOT writable by either the group or others. I know sendmail can be picky about that, and for good reason. Check out your /var/adm/syslog/mail.log file to see if any messages appear in there about the .forward file.
Experience gained while correcting a previous mistake is the best teacher imaginable!