Solved

Bash script to delete emails

Posted on 2011-09-15
4
304 Views
Last Modified: 2012-05-12
Hello

i need a script to delete emails from severals user accounts using criteria as number of messages or date (Ex. i need to launch a command and it to generate the deletion of emails from account1, account2, account3 that are older than 1st of september 2011)
Anyone can help?

Thank you in advance,
Cosmin
0
Comment
Question by:Cosmin Curticapean
  • 2
4 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 36543856
Where do these mailboxes reside?  What client program are your users using for their mail?
0
 

Author Comment

by:Cosmin Curticapean
ID: 36547746
I have linux/sendmail as mail server, using a local file for each mailbox. As client usually i use MS Outlook, but also Squirrel Webmail. The problem is that i have some users that don't cleanup their email box and i end up with old messages on the server that are useless. I know about the settings in Outlook to delete old messages, also to delete emails from webmail but i need a tool i can use directly from the server to parse each specified mailbox and cleanup messages. This has to be as automated as possible (cron).
0
 
LVL 19

Accepted Solution

by:
xterm earned 125 total points
ID: 36581475
This little script is awesome:  http://freshmeat.net/projects/mboxpurge/

Just do:

BOXES="account1 account2 account3"
for MBOX in `echo $BOXES`;
do
  mboxpurge.pl -m 2011-09-01 $MBOX
done

If you want do all the mailboxes in /var/spool/mail, just replace the "for" line above with:

for MBOX in `ls /var/spool/mail`;
0
 

Author Comment

by:Cosmin Curticapean
ID: 36597874
Hello

it works, i did the test just by running a command line with the following content:
perl mboxpurge.pl -m 2011-09-01 /usr/mail/***

Thank you,
Cosmin C.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now