Last active
May 9, 2019 04:03
-
-
Save coderofsalvation/8270415 to your computer and use it in GitHub Desktop.
simple bash email function using sendmail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sends email using sendmail | |
# usage: echo "my email message" | email "foo@bar.com" "new event happened" "serverX" "noreply@serverx.com" | |
email(){ | |
content="$(cat - )"; email="$1"; subject="$2"; fromname="$3"; from="$4" | |
{ | |
echo "Subject: $subject" | |
echo "From: $fromname <$from>"; | |
echo "To: $email"; | |
echo "$content" | |
} | $(which sendmail) -F "$from" "$email" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment