Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
recepients=(
"recipient@website.com"
)
sender="sender@website.com"
senderName="Sender Name"
# error handling
function err_exit { echo -e 1>&2; exit 1; }
# create message
function mail_input {
echo "ehlo $(hostname -f)"
echo "MAIL FROM: <$sender>"
echo "RCPT TO: <$1>"
echo "DATA"
echo "From: $senderName <$sender>"
echo "Reply-To: $senderName <$sender>"
echo "Subject: This is a subject"
echo "What a great email."
echo "."
echo "quit"
}
# mail_input
for i in "${recepients[@]}"
do
mail_input $i | nc localhost 25 || err_exit
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment