Send mail to yourself and read in your favourite client and configure the rules to move to directory.

2010-01-10 238 words 2 mins read

By default when you send a mail using sendmail, the mail goes to the default directory. What I wanted to do was, use rss2email, to send the mails and then sort them in different folders depending on the From address.

Sendmail uses procmail to deliver mail locally. So here’s what I had to do:

Configure the rss2email to send the mail to amit@localhost

Next, configure the procmail to deliver mail to my home directory. To do this we will use the procmailrc file in the home directory. The contents of the file are :

MAILDIR=$HOME/Maildir      #you’d better make sure it exists
DEFAULT=$MAILDIR/inbox   #completely optional
LOGFILE=/var/log/from   #recommended

This sets the folder for the mail delivery to $HOME/Maildir. The format for the mail file would be mbox and the filename used for mail delivery would be inbox. Ensure that the folder and file exists. Now we will add some rules to place the mail in the appropriate file(or folder in mbox terminology)

* ^From.*shell*

The rule states that if the from field contains shell then move the message to the commands file rather than inbox folder. You can add as many rules as you want and you are done.

To test your rule:

create a file called test.msg with the contents

From: shell commands

and run the command:

procmail ~/.procmailrc <test.msg

and check which file the message went to … and you are done.


Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it