Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail delete script

Status
Not open for further replies.

terrywashington

Technical User
Jun 28, 2001
185
US
Does anyone know of a script that will delete mail that has certain contents in the subject field?
 
This function is performed by the LDA not sendmail. The most common LDA is procmail. If you are not using it I recommend installing it. Once you have it installed you need to create a recipie in a .procmailrc file. Place the .procmailrc file in /home/mailusername.
A simple recipie like this will work

:0:
* ^Subject: all.*mail
/dev/null

This says: Anything that begins with "Subject: all" and contains the string "mail" (followed by anything, or nothing) somewhere after that is to be saved in the folder /dev/null

TIP: Use VI as your editor when creating recipies. pico -w will work too but as your recipies get more complicated vi makes more sense



There is no God, only 10001010
 
Thanks Rhinokiller. The .procmailrc file works perfectly! Is there a way to configure the file to filter for multiple subjects?
 
You can stack your recipies in the .procmailrc file

:0:
* ^Subject: all.*mail
/dev/null

:0:
* ^Subject: any.*junk
/dev/null

:0:
* ^Subject: more.*ofthesame
/dev/null

There is no God, only 10001010
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top