h1ghlevelb1ts

Sending mail on the (arch) command line

I handwired my own backup solution a while ago and apparently left out the important part of reporting. When the backup script is done a mail is sent to me depending on the result. It took some time for me to figure out how to do this but once I knew it was really easy. Install ssmtp:

sudo pacman -S ssmtp

As root - edit /etc/ssmtp/ssmtp.conf:

mailhub=<smtp.server>:<port>
AuthUser=<username>
AuthPass=<password>
UseSTARTTLS=YES

I use sendgrid as outgoing SMTP server but there are several other options. Setting up your own shouldn’t be to hard either.

Once you have this up and running you can send me an email like this:

echo 'Really cool post about sending mails' | mail -s 'Cool post' fredrik@eldfluga.se

mail boxes

Photo by Gregory Jordan.

comments powered by Disqus