Delete all mail in user's mailbox

monaghan

Well-Known Member
Jan 7, 2004
51
0
156
I have a user with over 100Mb of mail, they have not been monitoring their default mailbox and didn't set it to default to a mailbox they do monitor :(

I've been asked to purge the default mailbox, can I simply delete the user's /~username/mail/inbox ?

I've not yet converted to maildir (if that makes a difference)
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,466
31
473
Go on, have a guess
The kindest way is usually to empty it rather than delting it, i.e.

cat /dev/null > /path/to/inbox

or

>/path/to/inbox

if you prefer. However, there's usually no issue with simply deleting the file, exim will recreate it if it needs to to deliver new email.
 

WindyT

Active Member
Nov 30, 2004
39
0
156
On a related note,

How do you empty everyone's spam box across the server.
Ultimately, I'd like to set a cron to do this on Sunday nights.

Setting one spam box to empty is one thing, but I'm wary of trying a catchall to delete everyone's.

Or am I just going about this the wrong way?

Thanks
 

krystalx

Active Member
Mar 27, 2005
29
0
151
There is an article on removing spam via cron already search through the forums.

Thanks
 

rpmws

Well-Known Member
Aug 14, 2001
1,822
9
318
back woods of NC, USA
here is a quick question while we are on this subject. Let's say you are using maildir and a users new or cur folder has so many emails in it that you get an error when you do a rm * ?? something like too many arguments or files to delete.
 

casey

Well-Known Member
Jan 17, 2003
2,303
0
191
rpmws said:
here is a quick question while we are on this subject. Let's say you are using maildir and a users new or cur folder has so many emails in it that you get an error when you do a rm * ?? something like too many arguments or files to delete.
Good question. I had this same issue before with a non-mail directory. I ended up doing
rm -rf a*
rm -rf b*
rm -rf c*
and so on. It was a real pain.
 

casey

Well-Known Member
Jan 17, 2003
2,303
0
191
PWSowner said:
I've had to do that too, but I cheated and wrote a quick little script to do it for me. ;)
You smart people and your toys.... :p
 

Snowman30

Well-Known Member
PartnerNOC
Apr 7, 2002
679
0
316
cPanel Access Level
DataCenter Provider
If an account is using maildir how can we purge that specific account?

I found a site that has over 50000 emails in their catchall and its just way too slow to try and do it via webmail...
 

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
The nice thing about maildir is that it's really easy to remove (age) individual messages now - something like:

cd ~user/mail/theirdomain.com/person (alter as needed)
find cur new -name '????*' -mtime +14 -print | xargs rm -f

which removes files older than 14 days, the '????*' bit is to avoid removing "cur" or "new".