Skip to content

Instantly share code, notes, and snippets.

@carlcidromero
Last active November 4, 2024 17:42
Show Gist options
  • Save carlcidromero/90c3b531d897bc6a1be9099f47373f3e to your computer and use it in GitHub Desktop.
Save carlcidromero/90c3b531d897bc6a1be9099f47373f3e to your computer and use it in GitHub Desktop.
Basic Setup For Multiple Gmail Accounts In Neomutt

Basic Setup For Multiple Gmail Accounts In Neomutt

Just started using Neomutt, so my setup is still very basic.
It was quite a headache getting it to work with multiple Gmail accounts.
Hopefully the information below helps you and future me.

References

Be sure to allow less secure apps for each Gmail account

Directories And Files

~/
|── .neomutt/
|   ├── account.com.gmail.foo
|   ├── account.com.gmail.bar
|   ├── com.gmail.foo/
|   ├── com.gmail.bar/
└── .neomuttrc

~/.neomuttrc

# Default account
source "~/.neomutt/account.com.gmail.account1"

# Folder hooks
folder-hook 'account.com.gmail.account1' 'source ~/.neomutt/account.com.gmail.account1'
folder-hook 'account.com.gmail.account2' 'source ~/.neomutt/account.com.gmail.account2'

# Macros to switch accounts
macro index <f2> "<enter-command>unmailboxes *<enter><enter-command>source ~/.neomutt/account.com.gmail.account1<enter><sync-mailbox><change-folder>!<enter>"
macro index <f3> "<enter-command>unmailboxes *<enter><enter-command>source ~/.neomutt/account.com.gmail.account2<enter><sync-mailbox><change-folder>!<enter>"

# Mappings
## Fetch mail shortcut
bind index G imap-fetch-mail

# General settings
set editor='vim'

~/.neomutt/account.com.gmail.account1

set imap_user = "[email protected]"
set imap_pass = ""
set smtp_url = "smtp://[email protected]:587/"
set smtp_pass = ""

set from = "[email protected]"
set realname = "your name"

set folder = "imaps://[email protected]:993"
set spoolfile = "+INBOX"
set postponed = "+[Gmail]/Drafts"
set record = "+[Gmail]/Sent"
set trash = "+[Gmail]/Trash"

# Be sure to `mkdir -p` the following paths
set header_cache =~/.neomutt/com.gmail.account1/cache/headers
set message_cachedir =~/.neomutt/com.gmail.account1/cache/bodies
set certificate_file =~/.neomutt/com.gmail.account1/certificates

set move = no
set imap_keepalive = 900

set sort = reverse-threads
set sort_aux = last-date-received

~/.neomutt/account.com.gmail.account2

set imap_user = "[email protected]"
set imap_pass = ""
set smtp_url = "smtp://[email protected]:587/"
set smtp_pass = ""

set from = "[email protected]"
set realname = "your name"

set folder = "imaps://[email protected]:993"
set spoolfile = "+INBOX"
set postponed = "+[Gmail]/Drafts"
set record = "+[Gmail]/Sent"
set trash = "+[Gmail]/Trash"

# Be sure to `mkdir -p` the following paths
set header_cache =~/.neomutt/com.gmail.account2/cache/headers
set message_cachedir =~/.neomutt/com.gmail.account2/cache/bodies
set certificate_file =~/.neomutt/com.gmail.account2/certificates

set move = no
set imap_keepalive = 900

set sort = reverse-threads
set sort_aux = last-date-received
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment