The one-line solution
Paste the following into Terminal to reset your Mac Mail settings.
osascript -e 'tell application "Mail" to quit' 2>/dev/null; cp ~/Library/Containers/com.apple.mail/Data/Library/Preferences/com.apple.mail.plist ~/Desktop && defaults delete ~/Library/Containers/com.apple.mail/Data/Library/Preferences/com.apple.mail && sleep 3 && open -a Mail
Code language: JavaScript (javascript)
This creates a backup of the current settings on your Desktop then resets your Mail settings.
Command explanation
In macOS, preferences can be edited using the command line tool defaults
. Mac Mail has the bundle identifier com.apple.mail
so settings are stored in the plist with that name, within the sandbox container for that app.
- Quit the Mail app. Using AppleScript
tell application … to quit
we can automate this, and ignore if it fails (usually because Mail isn't running) using the semicolon. - Make a backup of the existing settings. Using
cp
to copy the preferences file, a backup is created on your Desktop. You should probably move this elsewhere if you wish to keep it. - Perform the reset. Using
defaults delete
we can delete the entirecom.apple.mail
domain, but since this is within the container we need to provide the full path. - Reopen Mail. You could do this by clicking on Mail, or using
open -a Mail
as we do in the command.
Running the above in Terminal will kill the Mail process, then regardless of whether that succeeded or not, it will copy the Mail.app preferences property list from its location in the com.apple.mail container to your Desktop and empty the property list in its original location, and if this succeeds it will open Mail.app.
To restore the settings from the backup, move com.apple.mail.plist from your Desktop back to the original location:
~/Library/Containers/com.apple.mail/Data/Library/Preferences/
Code language: JavaScript (javascript)
Thank you very much. Very useful approach and it really works!