IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

TkRat mini-HOWTO

Search Howtos :Match :
Next Previous Contents

6. Automatically sorting mail into folders

If you're like me, you get about 3,500 messages a day. Each time you fetch your mail, you have to wade through all the messages looking for particular ones that interest you.

This is not a problem anymore, thanks to Procmail.

Procmail works like this: Procmail examines each message as it is downloaded, and will perform a series of tasks based upon certain rules that you've specified.

Let's say, for example, that I get about 200 messages every day from a certain mailing list (in this example, I'm using the linux-foo list). Rather than have all those messages go directly into my main inbox, I would rather that they were automatically filtered into a box called "foo-list".

The first step is to take an example mail message that came from that mailing list and examine the mail headers.

I begin to notice a pattern. Every message that comes from that mailing list has a line that says:

Sender: owner-linux-foo at bar.foogers.com

I can now tell procmail to place every message that contains this line into a certain folder.

The way I tell this to procmail is by way of a ".procmailrc" file.

I will use my favorite text editor to create a text file in my home directory called ".procmailrc".

The file will look something like this:


LOGFILE=$HOME/.pmlog
MAILDIR=$HOME/mail
VERBOSE

# linux-foo list
:0 Hw
* ^.*[Ss]ender: owner-linux-foo at bar.foogers.edu
foo-list

# if it got to this point, put it in my new mail folder
:0 Hw
newmail

Examine the "[Ss]ender" line. You'll notice that that line is the one thing that all messages from that mailing list have in common.

That section is telling procmail that when it sees a message come through with a header that looks like the above, to put it into the "foo-list" folder.

The next section is saying that if the message matched nothing above, to just place it into newmail.

Now, let's say that anytime I get a message from my good friend, EJ, I want it to go into a folder called "EJ".

I'll just create a new section of my procmailrc file. See below:


LOGFILE=$HOME/.pmlog
MAILDIR=$HOME/mail
VERBOSE
 
# linux-foo list
:0 Hw
* ^.*[Ss]ender: owner-linux-foo at bar.foogers.edu
foo-list

# Message from E.J.!
:0 Hw
* ^.*[Ff]rom: ej at mypal.com
ej
 
# if it got to this point, put it in my new mail folder
:0 Hw
newmail

Notice the new section for EJ. When a message comes in with his E-Mail address in the "From" field, it will automatically place it into my "ej" folder.

Now, let's say that there's some lamer out there who keeps on E-Mailing me. I don't want to hear from him, but he's persistent. Once again - procmail to the rescue.

So, let's say I don't ever want to see any mail from Bill Gates. I can setup a recipe to delete any mail that comes from him. Look at my new procmailrc:



LOGFILE=$HOME/.pmlog
MAILDIR=$HOME/mail
VERBOSE
 
# Is it coming from Bill Gates?  If yes, DELETE IT!!!
:0 Hw
* ^.*[Ff]rom: bgates at microsoft.com
/dev/null

# linux-foo list
:0 Hw
* ^.*[Ss]ender: owner-linux-foo at bar.foogers.edu
foo-list
 
# Message from EJ!
:0 Hw
* ^.*[Ff]rom: ej at mypal.com
ej
 
# if it got to this point, put it in my new mail folder
:0 Hw
newmail

Now I have a rather nice procmailrc file. Let's examine what procmail will do to each message as it comes in.

At first, it checks the message to see if it is from "bgates at microsoft.com". If it is, delete it, and it's done.

If the message made it through the first check, it will see if it has the "owner-linux-foo at bar.foogers.edu" in the headers. If it does, it will put it into the "foo-list" folder, and it's done.

If the message still makes it past that, then it checks to see if it's from EJ. If it is, it places it into the "ej" folder.

Now, if the message passes all those tests, then it should just place it into my newmail folder.

Once you have these folders in place and procmail is properly filtering the mail, you can just go into TkRat, "Admin - New/Edit Folder" and create the folders for each filename. They will be located under /home/username/mail/foldername.


Next Previous Contents
Search Howtos :Match :
Python 3.0
Interpreted, interactive, object-oriented programming language
VLC media player 0.9.8a
Cross-platform media player and streaming server
Transmission 1.41 beta 2
Lightweight, yet powerful BitTorrent client
X-Moto 0.5.0
2D motocross platform game
Gdm 2.25.1
Reimplementation of the well known xdm program.
Linux Kernel 2.6 2.6.28-rc7
Linux Kernel
Linux Kernel 2.4 2.4.37
Linux Kernel
SquirrelMail 1.4.17
PHP Based Webmail Product
GNOME 2.25.2
GNOME desktop environment
WebGUI 7.6.5
A fully featured content management system.
Free IT Magazines, White Papers, eBooks, and more !
Dr. Dobb's Journal

Dr. Dobb's Journal enables programmers to write the most efficient and sophisticated programs and help in daily programming quandaries.

The 7 Things that IT Security Professionals MUST KNOW!

Gain key insight into security problem and find the safest means to protect your technological assets.

Database Trends and Applications

Provides timely coverage of the technology, intelligence and insight needed to plan, implement and manage information-rich projects.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info