#!/usr/bin/env bash
set -a; source ~/credentials.env; set +a

# requires credentials.env
# requires msmtp and .msmtp config

TO="alice@otherhost.com"
SUBJECT="Hello from msmtp"
{
    printf "From: %s\n"    "$SMTP_MAIL"
    printf "To: %s\n"      "$TO"
    printf "Subject: %s\n" "$SUBJECT"
    printf "\n"
    printf "This message was sent by msmtp.\n"
} | msmtp "$TO"

# for gmail (assumes account named 'gmail' in ~/.msmtprc):
# ... | msmtp --account=gmail "$TO"

