George Garside Blog

A place of many ramblings about macOS and development. If you find something useful on here, it's probably an accident.

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/ ~/Desktop && defaults delete ~/Library/Containers/ && sleep 3 && open -a Mail

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 so settings are stored in the plist with that name, within the sandbox container for that app.

  1. 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.
  2. 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.
  3. Perform the reset. Using defaults delete we can delete the entire domain, but since this is within the container we need to provide the full path.
  4. 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 preferences property list from its location in the container to your Desktop and empty the property list in its original location, and if this succeeds it will open

To restore the settings from the backup, move from your Desktop back to the original location:


Leave a Reply

No comments