x95u1

Using mutt email client with multiple IMAP accounts

Jan 19th, 2017
100
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 from=me@example.com
  25. set hostname="example.com"
  26. set folder="imaps://imap.example.com/"
  27. set postponed="=Drafts"
  28. set spoolfile="imaps://imap.example.com/INBOX"
  29. set signature="~/.mutt/signature.example"
  30. set smtp_url="smtp://me@mail.example.com" smtp_pass="$my_pw_example"
  31.  
  32. # .mutt/account.otherdomain
  33. set from=myself@otherdomain.tld
  34. set hostname="otherdomain.tld"
  35. set folder="imaps://imap.otherdomain.tld/"
  36. set postponed="=Drafts"
  37. set spoolfile="imaps://imap.otherdomain.tld/INBOX"
  38. set signature="~/.mutt/signature.otherdomain"
  39. set smtp_url="smtp://myself@mail.otherdomain.tld" smtp_pass="$my_pw_otherdomain"
  40.  
  41. Now all that's left to do is two folder-hooks to load the files:
  42. # .mutt/muttrc
  43. folder-hook 'example.com' 'source ~/.mutt/account.example'
  44. folder-hook 'otherdomain.tld' 'source ~/.mutt/account.otherdomain'
  45. # switch to default account on startup
  46. source ~/.mutt/account.example
  47.  
  48. A slight variation of the macros also uses the account files:
  49. macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/account.example<en
  50. ter><change-folder>!<enter>'
  51. macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/account.otherdomai
  52. n<enter><change-folder>!<enter>'
  53.  
  54. To save entering the password all the time, we use account-hooks:
  55. account-hook example.org 'set imap_user=me imap_pass=pw1'
  56. account-hook otherdomain.tld 'set imap_user=myself imap_pass=pw2'
  57.  
  58. Putting passwords in configs isn't something I like, so I pull them
  59. from the Gnome keyring:
  60. set my_pw_example=`gnome-keyring-query get mutt_example`
  61. set my_pw_otherdomain=`gnome-keyring-query get mutt_otherdomain`
  62. account-hook example.org 'set imap_user=me imap_pass=$my_pw_example'
  63. account-hook otherdomain.tld 'set imap_user=myself imap_pass=$my_pw_otherdomain'
  64.  
  65. (I found gnome-keyring-query in the [5]Gentoo Wiki.)
  66.  
  67. Martti Rahkila has [6]more verbose article with similar ideas.
  68.  
  69. Update 2013-01-02: smtp_url and smtp_pass added
  70. Tags: [7]debian [8]unix
  71. Last edited Mi 02 Jan 2013 12:00:14 CET
  72.  
  73. References
  74.  
  75. 1. https://www.df7cb.de/blog/index.html
  76. 2. https://www.df7cb.de/blog/2010.html
  77. 3. https://www.df7cb.de/blog/recentchanges.html
  78. 4. http://svn.df7cb.de/viewcvs.cgi/trunk/2010/Using_multiple_IMAP_accounts_with_Mutt.mdwn?root=blog&view=log
  79. 5. http://www.gentoo-wiki.info/HOWTO_Use_gnome-keyring_to_store_SSH_passphrases
  80. 6. http://www.acoustics.hut.fi/~mara/mutt/profiles.html
  81. 7. https://www.df7cb.de/blog/tag/debian.html
  82. 8. https://www.df7cb.de/blog/tag/unix.html
Add Comment
Please, Sign In to add comment