Solved

Bash script to delete emails

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Migrating an SQL 2008 database to Oracle 12c 3 89
Why isn't object file created? 6 42
su - oracle could not open session 6 52
expectj telnet failing 5 26
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…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

920 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

17 Experts available now in Live!

Get 1:1 Help Now