Solved

Bash script to delete emails

Posted on 2011-09-15
4
313 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Choosing CentOS 16 107
Remote desktop Ubuntu from Windows 10 5 90
php56-php-mcrypt for rhel7 php56 1 44
AWK use math to add new field - single file 5 36
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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