Skip to content

Instantly share code, notes, and snippets.

@jpcweb
Last active October 29, 2020 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpcweb/eb7e89ce4b3a310df2f82821ca05342d to your computer and use it in GitHub Desktop.
Save jpcweb/eb7e89ce4b3a310df2f82821ca05342d to your computer and use it in GitHub Desktop.
How to set up multiple accounts with [Mutt](http://www.mutt.org/) E-mail Client

How to set up multiple accounts with Mutt E-mail Client

Thanks to this article by Christoph Berg

Instructions

Directories and files

~/
|── .mutt/
|   ├── account.com.gmail.foo
|   ├── account.com.gmail.bar
|   ├── account.com.hotmail.xor
|   ├── com.hotmail.xor/
|   ├── com.gmail.foo/
|   └── com.gmail.bar/
└── .muttrc
~/.muttrc
# Settings and colors
source ~/.config/neomutt/settings
source ~/.config/neomutt/colors

# Folder hooks
folder-hook 'account.com.gmail.foo' 'source ~/.mutt/account.com.gmail.foo'
folder-hook 'account.com.gmail.bar' 'source ~/.mutt/account.com.gmail.bar'
folder-hook 'account.com.hotmail.xor' 'source ~/.mutt/account.com.hotmail.xor'

# Default account
source ~/.mutt/account.com.gmail.foo         

# Macros for switching accounts
macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/account.com.gmail.foo<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/account.com.gmail.bar<enter><change-folder>!<enter>'
macro index <f4> '<sync-mailbox><enter-command>source ~/.mutt/account.com.hotmail.xor<enter><change-folder>!<enter>'

# set mailcap
set mailcap_path = "~/.mailcap"

# gpg keys
set crypt_use_gpgme=yes
set postpone_encrypt = yes
set pgp_self_encrypt = yes
set crypt_use_pka = no
set crypt_autosign = no
set crypt_autoencrypt = no
set crypt_autopgp = yes
set pgp_sign_as=0x12345678

# Fetch mail shortcut
# bind index G imap-fetch-mail
bind index G last-entry
bind index g noop
bind index gg first-entry
bind index,pager \CP sidebar-prev       # Ctrl-Shift-P - Previous Mailbox
bind index,pager \CN sidebar-next       # Ctrl-Shift-N - Next Mailbox
bind index,pager \CM sidebar-open       # Ctrl-Shift-O - Open Highlighted Mailbox
bind editor <space> noop
bind pager,browser gg top-page
bind pager,browser G bottom-page
~/.mailcap
# HTML
# You need to install w3m on your system
text/html; w3m -I %{charset} -T text/html; copiousoutput;
text/plain; nvim %s

text/*; less
~/.config/neomutt/settings
# vim: filetype=muttrc

# set editor to neovim
# you'll need neovim on your system
set editor = "nvim"

set my_name = "Your_NAME"
set imap_check_subscribed

# Set preffered view modes
auto_view text/html text/calendar application/ics # view html automatically
alternative_order text/html text/plain text/enriched text/*

set mail_check = 120
set mail_check_stats = no

# main options
set envelope_from
set edit_headers                     # show headers when composing
set fast_reply                       # skip to compose when replying
set askcc                            # ask for CC:
set fcc_attach                       # save attachments with the body
set forward_format = "Fwd: %s"       # format of subject when forwarding
set forward_decode                   # decode when forwarding
set attribution = "On %d, %n wrote:" # format of quoting header
set reply_to                         # reply to Reply to: field
set reverse_name                     # reply as whomever it was to
set include                          # include message in replies
set forward_quote                    # include message in forwards
set text_flowed
unset sig_dashes                     # no dashes before sig
# unset mime_forward                   # forward attachments as part of body
# unset help                           # No help bar at the top of index
# set status_on_top                    # Status bar on top of index
set tmpdir = ~/.mutt/temp # where to keep temp files

unset confirmappend      # don't ask, just do!
set quit                 # don't ask, just do!!
unset mark_old           # read/new is good enough for me
set beep_new             # bell on new mails
set pipe_decode          # strip headers and eval mimes when piping
set thorough_search      # strip headers and eval mimes before searching
set timeout = 0

# status bar, date format, finding stuff etc.
set status_chars = " *%A"
set status_format = "[ Folder: %f ] [%r%m messages%?n? (%n new)?%?d? (%d to delete)?%?t? (%t tagged)? ]%>─%?p?( %p postponed )?"
set date_format = "%d.%m.%Y %H:%M"
set sort = threads
set sort_aux = reverse-last-date-received
set uncollapse_jump
set sort_re
set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"
set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
set send_charset = "utf-8:iso-8859-1:us-ascii"
set charset = "utf-8"
set arrow_cursor = "no" # Change `color indicator` depending

set header_cache = ~/.cache/mutt
# Store message locally
# Important disk usage be careful
set message_cachedir = ~/.cache/mutt

set sidebar_visible = yes
set sidebar_format = '%B%?F? [%F]?%* %?N?%N/?%S'

# cache optimisations
# use very high $read_inc to speed up reading hcache'd maildirs
folder-hook . 'set read_inc=2000'
~/.config/neomutt/colors
# vim: filetype=muttrc

# Header colors:
color header blue default ".*"
color header brightmagenta default "^(From)"
color header brightcyan default "^(Subject)"
color header brightwhite default "^(CC|BCC)"

mono bold bold
mono underline underline
mono indicator reverse
mono error bold
color normal default default
color indicator brightyellow default # currently selected message. default makes bar clear, disabled arrow to save space.
color sidebar_highlight red default
color sidebar_divider brightblack black
color sidebar_flagged red black
color sidebar_new green black
color normal brightyellow default
color error red default
color tilde black default
color message cyan default
color markers red white
color attachment white default
color search brightmagenta default
color status brightyellow black
color hdrdefault brightgreen default
color quoted green default
color quoted1 blue default
color quoted2 cyan default
color quoted3 yellow default
color quoted4 red default
color quoted5 brightred default
color signature brightgreen default
color bold black default
color underline black default
color normal default default

color body brightred default "[\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+" # Email addresses
color body brightblue default "(https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+" # URL
color body green default "\`[^\`]*\`" # Green text between ` and `
color body brightblue default "^# \.*" # Headings as bold blue
color body brightcyan default "^## \.*" # Subheadings as bold cyan
color body brightgreen default "^### \.*" # Subsubheadings as bold green
color body yellow default "^(\t| )*(-|\\*) \.*" # List items as yellow
color body brightcyan default "[;:][-o][)/(|]" # emoticons
color body brightcyan default "[;:][)(|]" # emoticons
color body brightcyan default "[ ][*][^*]*[*][ ]?" # more emoticon?
color body brightcyan default "[ ]?[*][^*]*[*][ ]" # more emoticon?
color body red default "(BAD signature)"
color body cyan default "(Good signature)"
color body brightblack default "^gpg: Good signature .*"
color body brightyellow default "^gpg: "
color body brightyellow red "^gpg: BAD signature from.*"
mono body bold "^gpg: Good signature"
color body red default "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a-f][0-9a-f])*@)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?|[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(:[0-9]+)?)|([a-z0-9_.!~*'()$,;:@&=+-]|%[0-9a-f][0-9a-f])+)(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?(#([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?|(www|ftp)\\.(([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?(:[0-9]+)?(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?(#([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?)[^].,:;!)? \t\r\n<>\"]"

# Default index colors:
color index yellow default '.*'
color index_author red default '.*'
color index_number blue default
color index_subject cyan default '.*'

# For new mail:
color index brightyellow black "~N"
color index_author brightred black "~N"
color index_subject brightcyan black "~N"

color progress black cyan
~/.mutt/account.com.gmail.foo
set imap_user = "foo@gmail.com"                       
set imap_pass = "<PASSWORD>"                                    
set smtp_url = "smtp://foo@smtp.gmail.com:587/"       
set smtp_pass = "<PASSWORD>"                                    
set from = "foo@gmail.com"                            
set realname = "Foo"                                  
set folder = "imaps://imap.gmail.com:993"                     
set spoolfile = "+INBOX"                                      
set postponed = "+[Gmail]/Drafts"                             
set header_cache = ~/.mutt/com.gmail.foo/cache/headers            
set message_cachedir = ~/.mutt/com.gmail.foo/cache/bodies         
set certificate_file = ~/.mutt/com.gmail.foo/certificates         
~/.mutt/account.com.gmail.bar
set imap_user = "bar@gmail.com"                       
set imap_pass = "<PASSWORD>"                                    
set smtp_url = "smtp://bar@smtp.gmail.com:587/"       
set smtp_pass = "<PASSWORD>"                                    
set from = "bar@gmail.com"                            
set realname = "Bar"                                  
set folder = "imaps://imap.gmail.com:993"                     
set spoolfile = "+INBOX"                                      
set postponed = "+[Gmail]/Drafts"                             
set header_cache = ~/.mutt/com.gmail.bar/cache/headers            
set message_cachedir = ~/.mutt/com.gmail.bar/cache/bodies         
set certificate_file = ~/.mutt/com.gmail.bar/certificates         
~/.mutt/account.com.hotmail.xor
set ssl_starttls=yes
set ssl_force_tls=yes

set imap_user = 'user_name@hotmail.com'
set imap_pass = 'password_here'
set from= $imap_user
set use_from=yes
set realname='Your_Name'
set folder = imaps://imap-mail.outlook.com:993
set spoolfile = "+INBOX"
set postponed="+[hotmail]/Drafts"
set mail_check = 100
set header_cache = "~/.mutt/com.hotmail.xor/cache/headers"
set message_cachedir = "~/.mutt/com.hotmail.xor/cache/bodies"
set certificate_file = "~/.mutt/com.hotmail.xor/certificates"
set smtp_url = "smtp://$imap_user@smtp-mail.outlook.com:587"
set smtp_pass = $imap_pass
set move = no
set imap_keepalive = 900
set record="+Sent"       
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment