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 [email protected]
tls on
tls_starttls on
tls_trust_file ~/.certs/equifax.pem
auth on
user [email protected]
password <password>
logfile ~/.msmtp.log
Then just call:
(echo "Subject: <subject>"; echo; echo "<message>") | msmtp <[email protected]>
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: [email protected]
To: [email protected]
Subject: Important message
Mime-Version: 1.0
Content-Type: text/html
<h1>Mail body will be here</h1>
The mail body <b>should</b> start after one blank line from the header.
And mail it like
cat email-template | msmtp [email protected]
The same can be done via command line as well, but it might be easier using a file.