How can I send an HTML email using a shell script?
Another option is using msmtp.
What you need is to set up your .msmtprc with something like this (example is using gmail):
account default
host smtp.gmail.com
port 587
from example@gmail.com
tls on
tls_starttls on
tls_trust_file ~/.certs/equifax.pem
auth on
user example@gmail.com
password
logfile ~/.msmtp.log
Then just call:
(echo "Subject: "; echo; echo "") | msmtp
in your script
Update: For HTML mail you have to put the headers as well, so you might want to make a file like this:
From: sender@domain.tld
To: email@domain.tld
Subject: Important message
Mime-Version: 1.0
Content-Type: text/html
Mail body will be here
The mail body should start after one blank line from the header.
And mail it like
cat email-template | msmtp email@domain.tld
The same can be done via command line as well, but it might be easier using a file.