LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Tags used in this thread
Popular LQ Tags ,

Reply
 
Thread Tools
Old 09-22-2007, 01:20 PM   #1
TastyWheat
Member
 
Registered: Aug 2003
Location: Texas
Distribution: Knoppix 5.0.1, Fedora Core 5
Posts: 65
Thanked: 0
Need Procmailrc Rule


[Log in to get rid of this advertisement]
I have a procmailrc file setup for my school account. It moves all external emails (i.e. emails from outside the school) to a seperate folder. I find that gets rid of almost all the spam. Some of my classmates prefer using Yahoo and Gmail so they'd get filtered out based on my current rule. I want to make a rule so their emails get put in my inbox (as an exception to the external mail rule). I can't find a rule that will accomplish this. I just want procmail to ignore those messages (treat them like normal).
TastyWheat is offline     Reply With Quote
Old 09-22-2007, 07:42 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware 13.0, -current
Posts: 3,887
Blog Entries: 1
Thanked: 27
You could just do something like (untested)
Code:
:0:
* ^From: .*\.(yahoo|gmail).com$
EXCEPTIONAL_MAILBOX
but that would probably give you back most of your spam. Something like a whitelist might be better:
Code:
# this is not a procmail standard variable
WHITELIST=$HOME/.procmailwl

:0:
* ^From:.*\/[a-z0-9_.+-]+@[a-z0-9_.-]+
* ? fgrep -qix "$MATCH" $WHITELIST
EXCEPTIONAL_MAILBOX
Just put the addesses of the people you want mail from in the whitelist, one per line or write a little script to process your mailboxes to generate the whitelist.

Some people plug in things like spamassasin to deal with spam explicitly, though.
slakmagik is offline     Reply With Quote
Old 09-27-2007, 07:33 PM   #3
TastyWheat
Member
 
Registered: Aug 2003
Location: Texas
Distribution: Knoppix 5.0.1, Fedora Core 5
Posts: 65
Thanked: 0

Original Poster
Is there something wrong with this rule?
Code:
# Send to special folder
:0
* ^From:.*friend1@gmail.com
* ^From:.*friend2@yahoo.com
* ^From:.*friend3@yahoo.com
$HOME/mail/safe-mail
I would've thought any emails from those addresses would be sent to 'safe-mail' but they're not. All messages are sent to my inbox.

This rule, however, works exactly like I would expect it to:
Code:
# Seperate email from external domain
:0
* !^From:.*myschool.edu
$HOME/mail/foreign-mail
I need to get the first rule working and I need it to work with the second rule. What am I missing?
TastyWheat is offline     Reply With Quote
Old 09-27-2007, 10:00 PM   #4
TastyWheat
Member
 
Registered: Aug 2003
Location: Texas
Distribution: Knoppix 5.0.1, Fedora Core 5
Posts: 65
Thanked: 0

Original Poster
Thumbs up Problem Solved

I made a very subtle mistake here. If multiple conditions are given then each condition must be true in order for the action to be taken. So this is what I actually needed to do:
Code:
# Emails from ANY of these addresses goes to a special folder
:0:
* ^From:.*friend1@gmail.com|^From:.*friend2@yahoo.com|\
  ^From:.*friend3@yahoo.com
$HOME/mail/safe-mail
I'm still not sure if the extra colon (for lockfiles) is necessary, but it doesn't hurt.

Last edited by TastyWheat; 09-27-2007 at 10:00 PM.. Reason: Wanted to add title.
TastyWheat is offline  
Tag This Post ,
Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Procmailrc filtering Intimidator Linux - Server 1 06-11-2007 08:30 AM
.procmailrc and BCC jayakrishnan Linux - Networking 1 03-10-2006 02:10 AM
.procmailrc jayakrishnan Linux - Networking 0 11-19-2005 03:13 AM
procmailrc davidsrsb Slackware 3 06-15-2005 12:07 PM
what's the max length of rule in .procmailrc? xeza Linux - Software 1 11-20-2003 10:28 AM


All times are GMT -5. The time now is 12:56 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration