-2

How can I delete emails from an individual email account? e.g. how can I empty userxyz@mydomain.com?

I know the following:

/var/spool/mail/mydomain 
/var/mail/mydomain

I have many inboxes some of them contain important email I don’t want to delete.

I tried delete all data in user mail cur/ and new/ in the following folder but when checked user quota still was the same.

/home/mydomain/mail/username/

Just to let you know I'm using CentOS.

slm
  • 369,824

1 Answers1

1

If you have a mail client like mutt available you can open those files directly like so:

$ mutt -f /path/to/mail/file

It may prompt you to create the following folder, $HOME/Mail, just say no (n) to this question.

/root/Mail does not exist. Create it? ([yes]/no):

You'll then be able to use t to tag any emails you don't want to keep. Once they've been tagged type the letter d to delete them.

Then simply exit mutt when you're done, q.

slm
  • 369,824
  • Sorry my Linux knowledge is not very good, if ask some silly questions. So that means any specific linux command like "rm", "mv" or "cp" will not work on this. What I mean just to go to the mail directory and delete or move files in the "cur" or "new" to clear mails inbox. – Fazli Hassan Oct 01 '14 at 11:26
  • Are you using maildir or mbox formatted mailboxes? – slm Oct 01 '14 at 11:27
  • WOW! that was quick. I user courier mail server if that makes sense? Also information can be found in three different location, like "/home/account/mail/", "/var/spool/mail/" and "/var/mail/account/". I don't know which one is correct and which one not. – Fazli Hassan Oct 01 '14 at 11:43
  • If you're asking how can I perform operation X on my mailboxes, then take a look at this Q&A: http://unix.stackexchange.com/questions/26790/how-can-i-use-the-mail-command. The mail command can be scripted to operate against your various inboxes. – slm Oct 01 '14 at 11:47
  • thanks for sharing with me a very nice application, I installed it and can open emails with it but, even when I clear the whole mailbox and check the quota in cpanel no changes to it. the quota still shows the same memory usage. whats going on there? – Fazli Hassan Oct 02 '14 at 16:02
  • @FazliHassan - pls confirm that the file shows it's size as 0 or smaller than before. – slm Oct 02 '14 at 16:09
  • these are the folders inside mailbox all of them size is more then 0, courierimapacl courierimapkeywords/ courierimapsubscribed courierimapuiddb cur/ .Drafts/ .Junk/ maildirsize new/ .Sent/ tmp/ .Trash/ – Fazli Hassan Oct 02 '14 at 16:25
  • @FazliHassan - and you ran mutt -f <file> against all of them? You'll need to do this to reduce the size of these files. – slm Oct 02 '14 at 16:49
  • ran through all the one starts with dot like .Sent/ opened and cleared a few emails there not in megs as the quota shows, other says not a mailbox. logged in to the email through browser, all empty, was full before, but the quota in cpanel shows still the same, not even 1M reduced. – Fazli Hassan Oct 03 '14 at 09:40
  • @FazliHassan - I would take this to mean that your mailboxes are not the source of your disk usage. You're asking 2 Q's. (1) How do I remove mail from the cmd line. (2) How do I reduce the space used by my CPanel acct. – slm Oct 03 '14 at 10:46
  • Trust me they are in the same server, as I mentioned in previous post when I used mutt and deleted emails on the server & checked emails in browsers all emails were deleted, about my questions because my main concern was to clear disk quota by deleting all emails at once from command. I thought by just deleting emails would clear the disk quota. – Fazli Hassan Oct 03 '14 at 16:29
  • I wasn't saying they're not on the same server, rather that your disk space being consumed by them must not be enough to show any impact on your quotas. – slm Oct 03 '14 at 17:14