Mutt imap: Difference between revisions
From wikinotes
Line 106: | Line 106: | ||
</blockquote><!-- Login Auth --> | </blockquote><!-- Login Auth --> | ||
=== OAUTH2 Auth === | ==== OAUTH2 Auth ==== | ||
<blockquote> | <blockquote> | ||
=== gmail-oauth2-tools === | === gmail-oauth2-tools === | ||
<blockquote> | <blockquote> |
Revision as of 17:23, 19 February 2024
Mutt can be configured to access emails remotely using an IMAP server. This is best for an email archive, which you may not want to constantly sync back-and-forth with the server.
Documentation
mutt manual http://www.mutt.org/doc/manual/#imap
Usage
# ======================= # Navigating IMAP folders # ======================= # navigate to inbox in sidebar c # change-folder ? # list-folders .. # now browse and select folder with <enter> # =============== # moving messages # =============== T Paystub # tag all paystub messages ;s # save all tagged messages to X folder ? # show folders
Account Types
Gmail
NOTE:
For gsuite accounts, set
set folder = imaps://<email@domain.com>@imap.gmail.com:993/"
Login Auth
~/.mutt/accounts/<account>
# ~/.mutt/accounts/<account> # # credentials only - used as-needed for auth # NOTE: created for account-hook, but it was difficult to restore folder settings afterwards. Just use folder-hooks. set smtp_url = "smtps://<your_email>@gmail.com@smtp.gmail.com:465/" set smtp_pass = "`<your-cli-password-cmd>`" set imap_user = "<your_email>@gmail.com" set imap_pass = "`<your-cli-password-cmd>`" set ssl_force_tls = yes
~/.mutt/folders/<account>
# ~/.mutt/folders/<account> # # folder settings only. accounts/* will be used when needed. source ~/.mail/accounts/<account> set folder = "imaps://<your_email>@imap.gmail.com:993/" set spoolfile = "+INBOX" bind index ^r imap-fetch-mail
~/.mutt/muttrc
Make your user/pass load on account switch# ~/.mutt/muttrc # add desired folders to sidebar mailboxes \ "imaps://<your_email>@imap.gmail.com:993/INBOX" \ "imaps://<your_email>@imap.gmail.com:993/filing/" \ "imaps://<your_email>@imap.gmail.com:993/filing/receipts" # reads when folder changes folder-hook imaps://<your_email>@imap.gmail.com:993/* 'source ~/.mutt/folders/<your_account>'
OAUTH2 Auth
gmail-oauth2-tools
Generate OAUTH2 Token
See gmail
Follow Authentication/OAUTH2 instructions to retrieve refresh token.
Download a copy of oauth2 script
- download script: https://github.com/google/gmail-oauth2-tools/blob/master/python/oauth2.py
- save to
~/.mutt/scripts/oauth2.py
~/.mutt/accounts/<account>
# ~/.mutt/accounts/<account> # # exclusively credentials info, settings in folders/* set imap_authenticators="oauthbearer" set imap_oauth_refresh_command="python2 ~/.mutt/scripts/oauth2.py \ --quiet \ --user=<your_email> \ --client_id=<client_id> \ --client_secret=<secret> \ --refresh_token=<token>
- use identical
~/.mutt/muttrc
and~/.mutt/folders/<account>
to LOGIN Auth described above.email-oath2-proxy
See https://github.com/simonrob/email-oauth2-proxy
I haven't tried this yet.
Tips/Tricks
Saving emails to a different IMAP account
macro index \cs '\ s\ ?\ c\ <backspace><backspace><backspace><backspace><backspace><backspace>\ <backspace><backspace><backspace><backspace><backspace><backspace>\ <backspace><backspace><backspace><backspace><backspace><backspace>\ <backspace><backspace><backspace><backspace><backspace><backspace>\ <backspace><backspace><backspace><backspace><backspace><backspace>\ <backspace><backspace><backspace><backspace><backspace><backspace>\ imaps://${your_email}@imap.gmail.com:993\ <Tab>\ <backspace><backspace><backspace><backspace><backspace><backspace>\ <Tab>'\ "Save message to +storage mailbox"