Skip to content

Instantly share code, notes, and snippets.

@ekhabarov
Forked from lazyfrost/mutt-gmail-yandex.md
Created August 27, 2016 20:22
Show Gist options
  • Save ekhabarov/c4e97bb9fc2af095592edfb94690099d to your computer and use it in GitHub Desktop.
Save ekhabarov/c4e97bb9fc2af095592edfb94690099d to your computer and use it in GitHub Desktop.
Configuring mutt to work with gmail and yandex

Configuring mutt to work with gmail and yandex

Information used:

So, thanks to authors for ideas and detailed tutorials how to get it working.

This mutt configuration is for 2 email accounts - gmail.com and yandex.ru,
using folder-hooks and account-hooks to switch between them.
It is simple and quick setup.

Structure of files and folders:

~/  
 |--.mutt/  
     |-- accounts.gpg
     |-- aliases 
     |-- muttrc
     |-- yandex  
     |-- gmail
     |-- mailcap  
     |-- gmail.com/  
     |   |-- cache/  
     |       |-- bodies/  
     |       |-- headers  
     |-- yandex.ru/  
     |   |-- cache/  
     |       |-- bodies/  
     |       |-- headers   
     

Files content:


accounts

set my_name        = 'Your Name'  
set my_gmail_user  = '[email protected]'  
set my_gmail_pass  = 'your_password_here'  
set my_yandex_user = '[email protected]'  
set my_yandex_pass = 'your_password_here'  

Encrypt this file with your personal key, or optionally generate new pair of key for this case:

gpg --gen-key  
gpg -e -r 'Your Name' accounts 
shred accounts && rm -f accounts  

muttrc

source "gpg -dq $HOME/.mutt/accounts.gpg |"

folder-hook 'gmail.com' 'source ~/.mutt/gmail'
folder-hook 'yandex.ru' 'source ~/.mutt/yandex'

source '~/.mutt/gmail'

account-hook gmail.com 'set imap_user=$my_gmail_user imap_pass=$my_gmail_pass'
account-hook yandex.ru 'set imap_user=$my_yandex_user imap_pass=$my_yandex_pass'

macro index <f2> '<change-folder>imaps://imap.gmail.com<enter>'
macro index <f3> '<change-folder>imaps://imap.yandex.ru<enter>'

set alias_file    = ~/.mutt/aliases
set sort_alias    = alias
set reverse_alias = yes
source $alias_file
set mailcap_path  = ~/.mutt/mailcap
auto_view text/html

gmail

# GENERAL OPTIONS
set header_cache     = ~/.mutt/gmail.com/cache/headers
set message_cachedir = ~/.mutt/gmail.com/cache/bodies
unset record

# RECEIVE OPTIONS
set imap_check_subscribed
unset imap_passive
set imap_keepalive = 900
set mail_check     = 1800

# REMOTE GMAIL FOLDERS
set folder    = 'imaps://imap.gmail.com:993'
set spoolfile = '+INBOX'
set postponed = '+[Gmail]/Черновики'

# SEND OPTIONS
set realname  = $my_name
set from      = $my_gmail_user
set smtp_url  = 'smtp://'$my_gmail_user'@smtp.gmail.com:587/'
set smtp_pass = $my_gmail_pass

yandex

# GENERAL OPTIONS
set header_cache     = ~/.mutt/yandex.ru/cache/headers
set message_cachedir = ~/.mutt/yandex.ru/cache/bodies

# RECEIVE OPTIONS
set imap_check_subscribed
unset imap_passive
set imap_keepalive = 900
set mail_check     = 1800

# REMOTE YANDEX FOLDERS
set folder    = 'imaps://imap.yandex.ru:993'
set spoolfile = '+INBOX'
set postponed = '+Черновики'
set record    = '+Отправленные'

# SEND OPTIONS
set ssl_starttls  = yes
set ssl_force_tls = yes
set realname      = $my_name
set from          = $my_yandex_user
set smtp_url      = 'smtps://'$my_yandex_user'@smtp.yandex.ru:465/'
set smtp_pass     = $my_yandex_pass

mailcap

text/html; w3m -I %{charset} -T text/html; copiousoutput;

Finally, create folders and files for headers and bodies cache

That's all. To switch between accounts press F2 and F3

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