Don't let Mail attachments accumulate and waste space

Possibly. I do know that if you use File > Save attachments… in Mail it does not keep a copy in

~/Library/Containers/com.apple.mail/Data/Library/Mail Downloads

It’s also possible that each time you install a new version of macOS (e.g., Catalina > Big Sur) it wipes the downloads folder.

1 Like

I just checked, and that folder contains thousands of items, nearly 12 GB, also dating back to 2013. All that has carried over through numerous system upgrades and migration to a new computer in 2020. (2019 iMac, currently Monterey 12.6.2)

That path does not exist in my Ventura 13.1. What does exist is 5 folders with this path:
~/Library/Containers/Mail/Data/Library/

Only two of them contain
~/Library/Containers/Mail/Data/Library/Mail Downloads/

And one of those is empty. The other one contains 177.3MB of data.

I’ve got 8400+ folders, about 7gb. They date back to May 2015 which is when I got this machine.

What a mess though! Why does Mail put them all in individual folders? It would be so much easier if they were all in one folder (like Eudora did)

Diane

So there is something really strange going on here with the way the Finder displays things. When I navigate to ~/Library/Containers in the Finder, I see SIX folders named “Mail”. But when I open a Terminal window and do:

ls  ~/Library/Containers | grep -i mail

I get

com.apple.MailCacheDelete
com.apple.MailServiceAgent
com.apple.MailShareExtension
com.apple.STMExtension.Mail
com.apple.diagnosticextensions.osx.maillogs
com.apple.mail
com.apple.mail.MailNotificationContentExtension
com.apple.mail.MailQuickLookExtension
com.apple.mail.SpotlightIndexExtension
com.apple.share.Mail.compose
com.apple.share.Mail.compose-back-to-sender

So clearly there’s a whole bunch of stuff going on here that the Finder pretends are all just folders named “Mail”.

Dave

Same here (on Big Sur, and I never use Apple’s Mail app). Interestingly, the six “Mail” folders have different icons:

If I do a “Get Info” on each, one however:

Screen Shot 2022-12-27 at 18.37.41

I can see that they each have different real-world names. The six “Mail” folders are actually::

  • com.apple.mail
  • com.apple.mail.MailQuickLookExtension
  • com.apple.MailShareExtension
  • com.apple.share.Mail.compose
  • com.apple.share.Mail.compose-back-to-sender
  • com.apple.STMExtension.Mail

GetFileInfo indicates that the C bit (meaning custom icon) is set and all other attributes are off:

$ GetFileInfo com.apple.mail
directory: "/Users/.../Library/Containers/com.apple.mail"
attributes: avbstClinmedz
created: 04/01/2013 18:07:16
modified: 12/14/2022 18:38:03

I don’t see any BSD extended attributes:

$ ls -ldO com.apple.mail
drwx------@ 6 ...  staff  - 192 Dec 14 18:38 com.apple.mail/

I’m not sure where the Finder is getting the custom name from. I looked at the two .plist files contained at the root level of each of these folders (using plutil -p filename) but didn’t find in there that might contain a different user-visible filename.

Yes, a mess it is.

On Big Sur, I have the six folders Dave6 mentioned, but I also have a Library/Mail/V8 folder (outside of Containers) which is a much bigger problem, literally, with currently 102 GB. I have never understood how to get rid of all the junk in there, despite the fact that I do exactly what fellwalker57 suggested, namely save pretty much all important attachments elsewhere (usually under a new name).

If someone has a suggestion how to save all the attachment files from that Library/Mail/V8 folder (e.g. on an external drive), and then just get rid of the attachments in that folder, that would be super helpful.

For me, /Library/Mail/V8 stores a copy of all the e-mails in my Archive and other folders. I know these are on iCloud but this folder stores a local copy. In my case it’s 2Gb which is about right so 102Gb sounds rather large. Does your Mail Archive folder contain so many messages that 102Gb is credible?

Mail does appear to be buggy. In my /Library/Mail/V8 folder I have .mbox folders for all the Mail folders: Drafts, Sent Messages, Deleted Messages, INBOX, etc. all of which are several megabytes even though I have no current e-mails in any of these folders in Mail. I have found that I can delete all the contents of these Library folders without adverse effects.

I do not know of an easy way to verify that all the mail in the V8 folder is the same as the mail you want to keep. On at least 2 occasions I have had to rebuild my Mac from scratch and each time it downloaded a fresh copy of all my emails from iCloud into Mail folders that were initially empty. So that meant I only had the mail I wanted. I don’t recommend that as a solution.

Just realized I also have a \Mail\Downloads folder. That has 900 individual items in it from April 2012-June 2013. I think it’s from the first email address I migrated over the Mail in 2012 and I wonder if earlier OS versions handled downloads more rationally.

Diane

One thing you need to understand about attachments is that the original is embedded into the message itself. Any that you find in an “Attachment” folder exists only if you chose to view it while reading the message (including images you choose to view) or download it. They are all duplicates of what is already coded into the original message. Those copies are deleted along with the message when deleted. So there is no harm in deleting all those found in “Attachment” folders since they can always be reproduced from the original message if needed. But there isn’t any way to automatically move them all to an external drive as they would almost certainly lose their connection to the original message.

So, when you say I can “delete an attachment and then reproduce it from the original message”, you probably mean I can reproduce it from the message on the IMAP mail server, correct? Technically, I want to save my attachments to certain folders and then get rid of the attachments, INCLUDING any copies on servers, so I have only 1 copy of each attachment (not counting backups, obviously).

I have 2 Gmail accounts (one private, one job-related), and both are near capacity (30+ out of 36 GB, I believe), so I really want to delete the attachments on the server too. For some reason, Gmail seems to make this really difficult, at least in bulk.

PS: Mail on High Sierra and probably other MacOS versions had a bug that produced extra copies of Mail attachments, sometimes thousands of copies (no kidding). Apparently a rare bug and only induced with certain Mailbox behaviors activated. I think this is solved now (with changed settings) but I cannot exclude there is some junk from that time still sitting around in my V8 folder.

Of course, you can save an attachment wherever you want. To get rid of the attached copy, choose Message > Remove Attachments.

If you do that, the message will no longer be associated with the file that was originally attached. If you open an old message, you are on your own finding where the attachment went. And, vice versa, the file will have no pointer back to the message it came from.

Hi Jeff,

I certainly use Message > Remove Attachments. In fact, I use it compulsively (in the form of ALT-CMD-A). Depending on the mail account, it may work, but often it doesn’t. Must be one of Mail’s numerous idiosyncrasies (or inabilities to cooperate with Gmail). I never understood why this isn’t a reproducible or even reliable behavior.

If you chose to use Message->Remove Attachments it will remove all embedded attachments from both your local copy and an iCloud IMAP message, but I haven’t yet verified that works the same way with a gmail account.

Does a “nuke and pave” on your Mac clear the Mail Downloads folder(s) out?

The tool CleanMyMac X (https://macpaw.com/cleanmymac) can remove Mail Attachments.

1 Like

Believe it does but not 100% sure.

No Containers directory on my Catalina system that I can locate. Oh, there it is. Hmm. That’s a whole of files, dating back several years, back to when I purchased this machine. Looks like it holds 682MB of data. Interestingly, from the command line, I cannot do an ls on the com.apple.mail directory or change to the ‘Mail Downloads’ folder.

1 Like

rbononno – there appears to be something odd about the ls command when applied to the Containers folder. It lists some of the folders in the directory but not all and it appears to list items that Finder doesn’t show (even when Finder is permitted to show hidden files). macOS prevents me from using ls on com.apple.mail too. But Finder does what I need.

Many (all?) of the folders in ~/Library/Containers have FinderInfo and data-container-personality extended attributes which (I believe) causes Finder to treat them special. I know, for instance, that six different such containers are presented by Finder a “Mail”. (See above ).

But I haven’t had any problem with ls. You just have to keep in mind that it is showing the real filenames, not Finder’s presentation of them. On my (Big Sur) system, I see all these locations just fine:

$ cd ~/Library/Containers

$ ls -l@d com.apple.mail
drwx------@ 6 dcharlap  staff  192 Dec 14 18:38 com.apple.mail/
	com.apple.FinderInfo	 32 
	com.apple.data-container-personality	2528064 

$ ls -l@ com.apple.mail
total 80
-rw-------@  1 dcharlap  staff  37016 Nov 10  2020 Container.plist
	com.apple.lastuseddate#PS	   16 
	com.apple.macl	   72 
drwx------  14 dcharlap  staff    448 Sep 27  2021 Data/

$ ls -R com.apple.mail
Container.plist		Data/

com.apple.mail/Data:
CloudKit	Documents	Library		Music		SystemData
Desktop		Downloads	Movies		Pictures	tmp

com.apple.mail/Data/CloudKit:
5148ba626ad2912bf4fd028b18d17b01bf5ed127	9aff907b8532e88139c729caf921db8f6052326c

com.apple.mail/Data/CloudKit/5148ba626ad2912bf4fd028b18d17b01bf5ed127:
AssetsDb	MMCS		Records
...

$ cd com.apple.mail
$ ls
Container.plist		Data

$ cd Data
$ ls
CloudKit	Documents	Library		Music		SystemData
Desktop		Downloads	Movies		Pictures	tmp

$ cd Library
$ ls
Application Scripts		Favorites			Mail
Application Support		Filters				Mail Downloads
Audio					FontCollections		PDF Services
Caches					Fonts				Preferences
Calendars				Images				QuickLook
ColorPickers			Input Methods		Saved Application State
ColorSync				KeyBindings			Sounds
Colors					Keyboard Layouts	Spelling
Components				Keychains			SyncedPreferences
Compositions			LaunchAgents		WebKit
Dictionaries			Logs

$ cd Mail\ Downloads