Setting up msmtp

msmtp

msmtp is a commandline smtp client that reads the message body from stdin.

configuration

You need to first install msmtp with the package manager of your choice.
After installing, create a confi file. msmtp looks for those in $XDG_CONFIG_HOME/msmtp. The config file simply needs to be called config.
Here’s a sample configuration file which you can edit:

defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /home/{user}/.config/msmtp/msmtp.log

account {account1}
host {smtp hostname}
port 465
from {from field}
user {smtp username}
passwordeval "gpg --quiet --for-your-eyes-only --no-tty --decrypt $XDG_CONFIG_HOME/msmtp/.msmtp-{account1}.gpg"
# only if your smtp server doesnt support STARTTLS
#tls_starttls off

# vim:filetype=msmtp

The last line exists to make vim highlight the configuration file with the right syntax. Feel free to remove it if you want.
Make sure you replace all your occurances of:

  • {user} - the username you are logged in to on your computer
  • {account1} - a string you have to reference later to select that profile
  • {smtp hostname} - the hostname of your smtp server
  • {smtp username} - the username you log in with on the given smtp server

usage

Using msmtp is very simple. Supply the body of the message via stdin, set a subject via the -s flag, set the account to use via the -a flag and send it to the email supplied at the very end.

Do you have a comment on one of my posts? Feel free to send me an E-Mail: witcher@wiredspace.de
To participate in a public discussion, use my public inbox: ~witcher/public-inbox@lists.sr.ht (Archive)
Please review the mail etiquette.

Posted on: May 21, 2020

Articles from blogs I read

I managed to stop biting my nails

watch out!Some sections of this article make nail biting sound appealing. If you're currently avoiding biting your own nails, please be careful reading in case they make you want to bite. Remove sentences from the article?For a long time, I haven'…

via Cadence's Weblog December 12, 2024

I'm daily driving Jujutsu, and maybe you should too

I’m not the first to write about how Jujutsu won me over. I’ve seen it off and on, and each time it came across my feed it was bumped a bit higher in my “list of things to look at eventually”. It finally reached the top spot, I think, when I saw Tony Finn’s …

via Drew DeVault's blog December 10, 2024

Launching the 2024 State of Rust Survey

It’s time for the 2024 State of Rust Survey! Since 2016, the Rust Project has collected valuable information and feedback from the Rust programming language community through our annual State of Rust Survey. This tool allows us to more deeply understand ho…

via Rust Blog December 5, 2024

Generated by openring