Created
May 5, 2016 22:06
-
-
Save ErikHarmon/6da634b7bd302a3c75c59ad9664848b2 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Easily test mail sending without anything but netcat. | |
# Instead of processing responses, it just slows down lines | |
# it sends and assumes it got a valid response. | |
FROM="$1" | |
TO="$2" | |
# Change these as appropriate. | |
EHLO="mail.example.com" | |
SERVER="example.com" | |
SUBJECT="Test Subject" | |
function delayit() { | |
IFS='\n' | |
while read i | |
do | |
echo "${i}" | |
sleep 1 | |
done | |
} | |
function msg() { | |
delayit <<EOF | |
ehlo ${EHLO} | |
MAIL FROM: <${FROM}> | |
RCPT TO: <${TO}> | |
DATA | |
EOF | |
cat - <<EOF | |
From: <${FROM}> | |
To: <${TO}> | |
Subject: ${SUBJECT} | |
Dear User, | |
This is a test email. | |
End of message. | |
. | |
EOF | |
sleep 1 | |
echo quit | |
} | |
msg | nc -v "${SERVER}" 25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment