I always install mutt when I’m setting up a server, mainly because I use it to send myself files from the command line, for local examination or archiving. Its quicker than using scp, ssh, or (heaven forbid) ftp. Plus you can use it in shell scripts. For example;
mutt -s "Log Files" -a /home/me/mail.log -- firstname.lastname@example.org
But recently I was troubleshooting a server which was sending out spam, and the mailbox of the server admin account was getting rather full of bounced messages. I didn’t want to delete them all, and I’d heard mutt described as ‘incredibly powerful’ so I decided to investigate. Turns out it was quite handy.
So I started up mutt in interactive mode, so I could see the Inbox. I knew I wanted to delete all the emails which had bounced from email@example.com, and this is how to do it.
- Shift+T — this gets into the Tag mode.
- ~b charliedontsurf — this looks for all emails with charliedontsurf in the body of the message and tags them.
- ;d — this takes all the tagged messages and marks them with the Delete flag. The semi colon tells mutt that the following command applies to all tagged mails. Any mutt command can be substituted.
You can repeat this as many times as you like. For example tagging messages with ‘~b 5.1.1’ will get all emails returned with a 5.1.1 User not found / mailbox unavailable tag.
To delete all these messages, press Q to quit, and say yes to the question ‘Purge xxxx deleted messages’.
Rather handy. I may use that one again.
Here’s a list of tagging patterns: http://www.mutt.org/doc/manual/manual-4.html#patterns