7

I have problems configuring mutt e-mail client on Lubuntu 18.04. 64 bit.

First I installed Mutt using command:

sudo apt install mutt

Everything was ok, but when I tried to add my e-mail account (Google or Yandex mail), I can't find muttrc configuration file?

I tried to locate it:

su-
updatedb
locate muttrc

This is the output:

/usr/lib/mutt/source-muttrc.d
/usr/share/doc/mutt/examples/ray.muttrc
/usr/share/doc/mutt/examples/sample.muttrc-compress
/usr/share/doc/mutt/examples/sample.muttrc-sidebar
/usr/share/doc/mutt/examples/sample.muttrc-tlr.gz
/usr/share/doc/mutt/examples/sample.muttrc.gz
/usr/share/man/man5/muttrc.5.gz

I went to all locations, I can't find muttrc file?
Can I create muttrc file in text editor and type in required data? If yes, what I need to include in muttrc file (which information)?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Blue11440
  • 73
  • 2
  • 5
  • Yes, it's a text file. Yes, you need to create it. No, we do not know what you need in the file. – thrig Jun 22 '18 at 13:50

1 Answers1

5

.muttrc

The Mutt configuration file is ~/.muttrc, i.e. the file called .muttrc in your home directory. It's up to you to create it and configure it. Mutt won't create it for you. With no configuration file, you just get the mail on your local machine (if you have local mail set up, which is not the case on Ubuntu by default).

Most email providers support IMAPS to read your mailbox and manage your emails, and SMTPS to send emails. Thus the bare minimum you need to use a remote account is to set smtp_url to the correct smtps:// URL and to navigate to a folder that is an imaps:// URL. You will probably want a few additional settings, including:

  • Caching.
  • Set the From: line with from and declare that same address as belonging to you with alternates.

Gmail

Note that for Gmail you'll need to either set up a per-application password (preferred) or enable plain IMAP access. What Gmail calls “less secure” is applications that use your “main” Gmail password to authenticate, as opposed to either the main password plus a second authentication factor or a per-application, non-memorable password.

Looking around I find a surprising number of incomplete tutorials. There's a lot of information in the Arch wiki, as usual, but it's a bit hard to digest. I'll try to be complete here but I don't actually use Mutt for Gmail so this is untested, comments welcome. Assuming that your Gmail address is [email protected] and your application password is qwertyuiop, your .muttrc should contain something like this.

set my_address = [email protected]
set smtp_pass = qwertyuiop

set imap_user = $my_address
set imap_pass = $smtp_pass
set smtp_url = smtps://[email protected]:465/
set folder = imaps://imap.gmail.com:993
set postpones = Drafts
unset record  # Gmail does this automatically

set spoolfile = +INBOX
mailboxes +INBOX

set from = $my_address
alternates $my_address

set message_cachedir = ~/.cache/mutt
set header_cache = $message_cachedir

If you don't want to keep your password in your configuration file, see Mutt: how to safely store password?

Accessing multiple accounts

Mutt is a bit awkward when it comes to having multiple accounts. The way it works is, you put all the commands to configure each account in hooks. When you switch from one account to another, Mutt runs the hook commands. The SMTP and IMAP configuration commands go in the account-hook while the rest (record, from, …) go into folder-hook. The alternates and mailboxes settings are a list that should contain one entry per account.

Alternatively, use a separate configuration file for each account. It's less convenient but simpler.

Alternatively, use OfflineIMAP to retrieve email from all your accounts, and use Mutt purely locally (except for sending).

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • Why is mutt designed to keep a password in txt file? – Evgeny Dec 20 '18 at 06:35
  • @EPo Presumably, because it keeps all of its configuration in a text file. Where else? Text files are standard and work everywhere. Password managers each have their own interface. And mutt *does* support passwords in a password manager via the `source` command: https://unix.stackexchange.com/questions/20570/mutt-how-to-safely-store-password – Gilles 'SO- stop being evil' Dec 20 '18 at 07:42
  • I guess there where some design tradeoffs at the time of making - [Mutt manual](https://wiki.archlinux.org/index.php/mutt#Passwords_management) itself reminds _writing your password in .muttrc is a security risk_. For git for example I'm forced to use a [credential manager](https://github.com/Microsoft/Git-Credential-Manager-for-Windows), it looks a more secure default option. – Evgeny Dec 20 '18 at 17:13
  • Gilles, what is the `unset record` for in Mutt? Is it to disable the record var? [Here](https://stackoverflow.com/a/53060012/1705829) set record='/dev/null' is used for not storing emails. Another one: Can I omit 'alternates' if I have one account? – Timo Feb 28 '22 at 14:45
  • I got 2 errors with the script: 1) Error in /home/.muttrc, line 8: postpones: unknown variable, source: errors in /home/.muttrc 2) SASL authentication failed – Timo Feb 28 '22 at 14:50
  • ok, my first question is solved, see Arch Wiki -> Mutt: Gmail automatically saves sent e-mail to +[Gmail]/Sent, so we do not want duplicates. unset record – Timo Feb 28 '22 at 14:51