Solved

Bash script to delete emails

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Centos 7 User to Start Apache, MariaDB, LDAP 5 39
nagios 4 php error after installation 6 92
How to learn Linux? 10 61
Using an inventory file in a script 7 30
Utilizing an array to gracefully append to a list of EmailAddresses
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

773 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