3

I use mutt with two different imap accounts, and have configured smtp accounts A and B with msmtp and mutt.

If I don't specify a default account in .msmtprc, mutt complains there is no default account when I try to send.

If I set a default account A, mutt uses this for all imap accounts.

How can I make it use the smtp account B for the corresponding imap account?

In the account B mutt config file I've set the following:

## sent set sendmail="/usr/bin/msmtp" set use_from=yes set realname="My Name" set [email protected] set hostname="gmail.com" set ssl_force_tls=yes set imap_pass=$my_pass unset ssl_starttls 

in .msmtprc the account configuration reads:

defaults tls on port 587 [...] account gmail tls_fingerprint 39:7C:59:20:DE:55:51:F4:8B:72:1D:B5:B2:26:8A:D1:DB:90:C6:28:80:77:F9:B5:EC:C1:BF:1C:6F:4D:A1:63 from [email protected] host smtp.gmail.com auth on user [email protected] passwordeval gpg2 --no-tty -q -d ~/mygmail.gpg 

2 Answers 2

3

Inside your mutt configuration for the account (either A or B), you use:

set sendmail="/usr/local/bin/msmtp -a [account] 

which tells msmtp which account parameters to use in .msmtprc. In my msmtp config, I specifically set the default to be na which forces the account to be set in mutt.

2
  • Two things: 1) I think this may need another " and 2) Why does this not work for me at all? It just gives me the error -a: unknown variable ??? Commented Jun 8, 2019 at 18:52
  • @gskapka - if you end the line with closing the quotation as you properly suspect, you shouldn't get the message "unknown variable". I too had a quotation problem, but it was after a send-hook. send-hook '~f "@gmail."' 'set sendmail="/usr/bin/msmtp -a gmail"' Commented Jul 18, 2020 at 10:36
2

there's section "Using msmtp with Mutt" within the EXAMPLES to the end of man msmtp.

The envelope_from=yes option lets Mutt use the -f option of msmtp. Therefore msmtp chooses the first account that matches the from address [email protected].

This means in practice: do not specify an account in mutts set sendmail path to msmtp. But use some keyboard macro to switch between identities (and from) before sending. For the keyboard marco there are different ways - one of is mentioned in the manual. I'll give you another one and you can choose:

.muttrc

set sendmail="/usr/bin/msmtp" set use_from=yes set envelope_from=yes alias gmail Horton Bumblebee <[email protected]> alias example H. Bumblebee <[email protected]> macro compose v "<edit-from>^Uidentity\_<tab>" "Select from" 

.msmtprc

defaults ... account gmail host imap.gmail.com from [email protected] ... account example host mail.example.com from [email protected] ... 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.