Skip to content

Instantly share code, notes, and snippets.

@thedanhub
Created November 14, 2021 09:13
Show Gist options
  • Save thedanhub/290b4f39e09a69a89d119ea93a2b9aff to your computer and use it in GitHub Desktop.
Save thedanhub/290b4f39e09a69a89d119ea93a2b9aff to your computer and use it in GitHub Desktop.
Export emails and account configuration from Mail.app in macOS to move to a new Mac
#!/bin/bash
echo [1/4] Creating MailExport folder on the Desktop
folder=/Users/$(whoami)/Desktop/MailExport
mkdir -p $folder
echo [2/4] Exporting mail...
cp -R /Users/$(whoami)/Library/Mail $folder
echo [3/4] Exporting account information...
cp -R /Users/$(whoami)/Library/Accounts $folder
echo [4/4] Exporting Mail preferences...
cp /Users/$(whoami)/Library/Preferences/com.apple.accounts.plist $folder
cp /Users/$(whoami)/Library/Preferences/com.apple.accountsd.plist $folder
cp /Users/$(whoami)/Library/Preferences/com.apple.mail-shared.plist $folder
echo Done! Mail.app mail and configuration has been exported to $folder
@thedanhub
Copy link
Author

thedanhub commented Nov 14, 2021

Requires Full Disk Access by Terminal.app in System Preferences > Security & Privacy > Privacy in order to be able to copy folders inside the user's Library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment