x95u1

Using mutt email client with multiple IMAP accounts

Jan 19th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. [1]Christoph Berg's Blog/ [2]2010/ Using multiple IMAP accounts with
  2. Mutt
  3. * [3]RecentChanges
  4. * [4]History
  5.  
  6. Mutt's configuration is sometime more a toolbox than something offering
  7. ready solutions, and "how to I use multiple accounts?" is one of the
  8. most FAQs. Here's a condensed version of my setup.
  9.  
  10. In the most simple solution, just 'c'hange folders to the IMAP server:
  11. c imaps://imap.example.com <enter>
  12. c imaps://imap.otherdomain.tld <enter>
  13.  
  14. That's cumbersome to type, so let's automate it:
  15. # .mutt/muttrc
  16. macro index <f2> '<change-folder>imaps://imap.example.com<enter>'
  17. macro index <f3> '<change-folder>imaps://imap.otherdomain.tld<enter>'
  18.  
  19. That would be the basic setup.
  20.  
  21. The two accounts have settings associated with them, we put them in two
  22. files:
  23. # .mutt/account.example
  24. set hostname="example.com"
  25. set folder="imaps://imap.example.com/"
  26. set postponed="=Drafts"
  27. set spoolfile="imaps://imap.example.com/INBOX"
  28. set signature="~/.mutt/signature.example"
  29. set smtp_url="smtp://[email protected]" smtp_pass="$my_pw_example"
  30.  
  31. # .mutt/account.otherdomain
  32. set hostname="otherdomain.tld"
  33. set folder="imaps://imap.otherdomain.tld/"
  34. set postponed="=Drafts"
  35. set spoolfile="imaps://imap.otherdomain.tld/INBOX"
  36. set signature="~/.mutt/signature.otherdomain"
  37. set smtp_url="smtp://[email protected]" smtp_pass="$my_pw_otherdomain"
  38.  
  39. Now all that's left to do is two folder-hooks to load the files:
  40. # .mutt/muttrc
  41. folder-hook 'example.com' 'source ~/.mutt/account.example'
  42. folder-hook 'otherdomain.tld' 'source ~/.mutt/account.otherdomain'
  43. # switch to default account on startup
  44. source ~/.mutt/account.example
  45.  
  46. A slight variation of the macros also uses the account files:
  47. macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/account.example<en
  48. ter><change-folder>!<enter>'
  49. macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/account.otherdomai
  50. n<enter><change-folder>!<enter>'
  51.  
  52. To save entering the password all the time, we use account-hooks:
  53. account-hook example.org 'set imap_user=me imap_pass=pw1'
  54. account-hook otherdomain.tld 'set imap_user=myself imap_pass=pw2'
  55.  
  56. Putting passwords in configs isn't something I like, so I pull them
  57. from the Gnome keyring:
  58. set my_pw_example=`gnome-keyring-query get mutt_example`
  59. set my_pw_otherdomain=`gnome-keyring-query get mutt_otherdomain`
  60. account-hook example.org 'set imap_user=me imap_pass=$my_pw_example'
  61. account-hook otherdomain.tld 'set imap_user=myself imap_pass=$my_pw_otherdomain'
  62.  
  63. (I found gnome-keyring-query in the [5]Gentoo Wiki.)
  64.  
  65. Martti Rahkila has [6]more verbose article with similar ideas.
  66.  
  67. Update 2013-01-02: smtp_url and smtp_pass added
  68. Tags: [7]debian [8]unix
  69. Last edited Mi 02 Jan 2013 12:00:14 CET
  70.  
  71. References
  72.  
  73. 1. https://www.df7cb.de/blog/index.html
  74. 2. https://www.df7cb.de/blog/2010.html
  75. 3. https://www.df7cb.de/blog/recentchanges.html
  76. 4. http://svn.df7cb.de/viewcvs.cgi/trunk/2010/Using_multiple_IMAP_accounts_with_Mutt.mdwn?root=blog&view=log
  77. 5. http://www.gentoo-wiki.info/HOWTO_Use_gnome-keyring_to_store_SSH_passphrases
  78. 6. http://www.acoustics.hut.fi/~mara/mutt/profiles.html
  79. 7. https://www.df7cb.de/blog/tag/debian.html
  80. 8. https://www.df7cb.de/blog/tag/unix.html
Add Comment
Please, Sign In to add comment