#!/usr/bin/env bash err() { errpre="" errpost="" if test -t 1; then ncolors=$(tput colors) if test -n "$ncolors" && test "$ncolors" -ge 8; then errpre="$(tput setaf 1)" errpost="$(tput setaf 7)" fi fi >&2 echo "${errpre}ERROR: $*${errpost}"; usage; exit 1 } warn() { pre="" post="" if test -t 1; then ncolors=$(tput colors) if test -n "$ncolors" && test "$ncolors" -ge 8; then pre="$(tput setaf 3)" post="$(tput setaf 7)" fi fi >&2 echo "${pre}WARNING: $*${post}" } usage() { >&2 cat <&2 echo "Finished reading body. Sending email..." swaks --auth \ --server smtp.mailgun.org \ --au "$username" \ --ap "$password" \ --to "$recipient" \ --h-Subject: "$subject" \ --body "$body"