A simple hack to start the agent is to execute a external command in your muttrc using the backtick ` command` syntax. If gpg prompt for the passphrase cannot be issued, then start the gpg-agent before.
Normally this is sufficient for a GUI password prompt to appear when, for example, sending a message from Mutt. ~/.msmtprc passwordeval "gpg -quiet -for-your-eyes-only -no-tty -decrypt ~/.mail/.msmtp-credentials.gpg" Remove the plain text file and move the encrypted file to the final location, e.g. $ gpg -default-recipient-self -e /path/to/plain/password Then, encrypt the file with your private key: In that directory create a plain text file with the mail account password. Create a secure directory with 700 permissions located on a tmpfs to avoid writing the unencrypted password to the disk. Then, create an encrypted password file for msmtp, as follows. To do this, set up GnuPG, including gpg-agent to avoid having to enter the password every time. For such cases, the -passwordeval parameterĬan be used to call an external keyring tool like GnuPG. msmtp will not prompt if it has been called by another type of application, such as Mutt. In that case, if the account in question has auth set to a legitimate value other than off, invoking msmtp from an interactive shell will ask for the password before sending mail. Msmtp should now find the password automatically.
Secret-tool store -label=msmtp host service smtp user yourusername
Setup the keyring as described on the linked wiki page and install libsecret. Storing passwords in GNOME Keyring is supported natively in msmtp. Passwords for msmtp can be stored in plaintext, encrypted files, or a keyring.
The ending dash is not a typo, rather it causes gpg to use stdin. To avoid this, use gpg with shell stdin: gpg -encrypt -o. Warning: Most shells save command history(e.g.bash_history. The following is an example of a msmtp configuration (the file is based on the per-user example file located at /usr/share/doc/msmtp/msmtprc-user.example the system configuration file belongs at /etc/msmtprc and its corresponding example file is located at /usr/share/doc/msmtp/msmtprc-system.example). Since msmtp version 1.8.6 you can place your user configuration either at ~/.msmtprc or $XDG_CONFIG_HOME/msmtp/config. Additionally, install msmtp-mta, which creates a sendmail alias to msmtp.