MacMail / Terminal option to Delete Messages

0

Anyone know the location / path, where one can DELETE messages in MacOS MacMail, using Terminal (Unix)?

Currently installation is: MacOS X El Capitan [10.11.5].

I have a very stubborn junk mail which I've Trashed, but I cannot delete it via the keyboard, menus, or any other way within the MacMail Program. I hope someone can direct me to the Unix Path, where I could do this.

There has been no-joy, trying to find the path/location myself in SuperUser [Q/A pairs] or via Internet -- with simple, no-frills explanation to Delete this email (and so I can do this subsequently of any other stubborn ones).

I know to select/use: SUDO via Terminal, so I could obtain permissions; yet, I just cannot find the location of the actual Email Files, from the Terminal command-line as I know not the path.

My appreciation is great for anyone willing to offer this advice. Thanks.

Phil H

Posted 2016-10-13T00:34:48.883

Reputation: 1

Answers

0

In the terminal first change to

cd 
cd Library/Mail/V3/

then you have to change to the directory for your mail account, this might be something like IMAP-user@host. IN this directory there are subdirectories with the extension .mbox, for INBOX, Trash or whatever folders you have created. Within these folders you find a folder with some UUID name and therein a Data folder. So for the INBOX on my host I end up with :

/Users/Username/Library/Mail/V3/IMAP-mail@usermailhost/INBOX.mbox/8E161FF7-2EA5-49DE-B2CB-221305BA3488/Data

In this folder there are subfolders named Messages and 0...9 (and they again have subfolders), but these contain the *.emlx files which are the actual mails.

To find an actual email you can run from within that directory something like

find . -name \*.emlx -exec grep -i "searchstring" {} \; -print

Once you identified the mail you could delete the file. After that I would go to Mail.app, select the mailbox and from the mailbox menu select rebuild.

And: Backup your data before doing this on your own risk.

P.J.Meisch

Posted 2016-10-13T00:34:48.883

Reputation: 126