trying to figure out a cli way to empty all email from a specific email account.

It is certainly possible to type:

mutt -f account
D
~s .*
then quit....

Is there a way to do this all from cli/cron?

link|improve this question

73% accept rate
1  
How is the mail stored? How are you accessing it? What type of mail storage is in use (mbox/maildir/other)? – Zoredache Nov 22 '11 at 18:03
/var/spool/mail/ :) Local email accounts. No need for pop3/imap account stuff right now. – Clustermagnet Nov 22 '11 at 18:06
why do you want to do this? – warren Nov 22 '11 at 20:33
feedback

2 Answers

up vote 4 down vote accepted

But echo -n > /var/spool/mail/account does the trick.

link|improve this answer
Make sure to do this as the user in question and not root or the file will end up with the wrong ownership. – Ladadadada Nov 22 '11 at 19:55
exactly why it would be nicer to bang this out via mutt, no? :) hence the mutt question, not a trick with echo/touch/etc :) – Clustermagnet Nov 22 '11 at 20:04
2  
(+1) So you'd rather have Mutt analyze every mail header and "re-render" an empty mailfile using billions of CPU and Disk cycles? Do the echo. It doesn't matter who you do it as if the file already exists the permissions will not be changed. Also, just for cleanliness lets do echo -n > /var/spool/mail/account so it doesn't start with a newline. – Kyle Smith Nov 22 '11 at 20:30
You don't need the echo. >/var/spool/mail/account works and leaves a blank file rather than one with a linfeed in it. – Iain Nov 22 '11 at 22:06
feedback

Would rm /var/spool/mail/account do the trick ?

link|improve this answer
dont know... that depends if postfix/dovecot wont complain about its absence, and recreate it! – Clustermagnet Nov 22 '11 at 18:42
That was rhetorical. – mailq Nov 22 '11 at 18:55
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.