?
Solved

Filtering Mail with Perl

Posted on 1998-10-20
3
Medium Priority
?
214 Views
Last Modified: 2010-03-04
What I am needing to do is install a script onto a UNIX system that will allow all of the e-mail coming to my address to be filtered based on the from address or the subject.  I want the mail to either be deleted, forwarded, or have nothing happen to each message - based on what I specify.  Do you know of any way I can do this, or know of a program that will do this?  Your help would be greatly appreciated!
0
Comment
Question by:jeikenb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 400 total points
ID: 1205554
procmail will do all of this, as well as much more.  In fact, chances are it's already on your system, and your system directory is checked for a .procmailrc each time you get mail.  Try

man procmail

and then

man procmailrc

Warning: procmail recipes are non-trivial, but have nothing to do with perl.
0
 

Author Comment

by:jeikenb
ID: 1205555
Thanks for the suggestion, but it doesn't work on my system.  We are running BSDI 3.1 and I can't find anything in regards to procmail on the server.  Do you have any other suggestions?
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1205556
I find it very surprising that bsdi doesn't include procmail, or
something with equivalent (superset) functionality.

( BTW, most of this info is from the procmail man file)

In any case, if you download and install procmail (say, in ~/bin), and
then put the following in your .forward file

|IFS=' '&&p=/ms/dist/aurora/bin/procmail&&test -f $p&&exec $p
-Yf-||exit 75 #YOUR_USERNAME

(note, that's all on one line, and your .forward _must_ be
world-readable).

Finally, if you don't have .forward functionality, get a new system
administrator. OK, try that again.  If you don't have .forward
functionality, you can run procmail manually or from a cron job via
the following script:

#!/bin/sh

ORGMAIL=/var/spool/mail/$LOGNAME

if cd $HOME &&
    test -s $ORGMAIL &&
    lockfile -r0 -l1024 .newmail.lock 2>/dev/null
then
    trap "rm -f .newmail.lock" 1 2 3 13 15
    umask 077
    lockfile -l1024 -ml
    cat $ORGMAIL >>.newmail &&
    cat /dev/null >$ORGMAIL
    lockfile -mu
    formail -s procmail <.newmail &&
    rm -f .newmail
    rm -f .newmail.lock
fi
exit 0

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question