0

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 from=my@gmail.com
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 my@gmail.com
host smtp.gmail.com
auth on
user my@gmail.com
passwordeval gpg2 --no-tty -q -d ~/mygmail.gpg
2

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.

  • 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 ??? – gskapka Jun 8 at 18:52
0

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 you@example.com.

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 <hobumbl@gmail.com>
alias example  H. Bumblebee <hbum@example.com>
macro compose v "<edit-from>^Uidentity\_<tab>" "Select from"

.msmtprc

defaults
 ...

account gmail
  host imap.gmail.com
  from hobumbl@gmail.com
  ...

account example
  host mail.example.com
  from hbum@example.com
  ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.