Skip to content

Instantly share code, notes, and snippets.

@dado3212
Created September 27, 2017 20:22
Show Gist options
  • Save dado3212/e495e0bf78f318d7f796ba3d65105073 to your computer and use it in GitHub Desktop.
Save dado3212/e495e0bf78f318d7f796ba3d65105073 to your computer and use it in GitHub Desktop.
#!/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