Created
March 31, 2018 13:49
-
-
Save inbasic/0c2314e00df05b7fc6b0bb24a928dfd4 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
if [[ $# -eq 0 ]] ; then | |
echo 'no input query' >&2 | |
exit 1 | |
fi | |
email=$(echo $1 | grep -i -o '[A-Z0-9._%+-]\+@[A-Z0-9.-]\+\.[A-Z]\{2,4\}') | |
if [[ $email == my_email_address ]] | |
then | |
server="email_server:587" | |
password="my_password" | |
fi | |
if [[ -z "$server" ]] | |
then | |
echo 'no server for '"$email" >&2 | |
exit 1 | |
fi | |
/usr/local/bin/swaks swaks -server $server \ | |
-tls --auth-user "$1" --auth-password $password \ | |
--to "$2" \ | |
--from "$1" \ | |
--body "$3" \ | |
--add-header "MIME-Version: 1.0" --add-header "Content-Type: text/html" \ | |
--header "Subject: $4" \ | |
--header "In-reply-to: $5" \ | |
--header "References: $6" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment