Created
August 25, 2013 15:55
-
-
Save thonixx/6334628 to your computer and use it in GitHub Desktop.
Test mail delivery (to check if e-mail account is configured on the remote server)
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
# test mail delivery | |
# scripted by github.com/thonixx | |
function maildelivery { | |
domain=$(echo "$1" | awk -F@ '{print $2}') | |
mailserver=$(dig mx $domain +short | awk {'print $2'} | head -n 1) | |
# test if something is in the output | |
if [ -z "$mailserver" ] | |
then | |
echo "There was no mailserver or no MX record. :(" | |
return | |
fi | |
# custom server to connect to | |
if [ ! -z "$2" ] | |
then | |
mailserver="$2" | |
fi | |
echo "Email: $1" | |
echo "Server: $mailserver" | |
echo "" | |
(echo "helo test" | |
sleep 2 | |
echo "MAIL FROM:<info@test.com>" | |
sleep 2 | |
echo "RCPT TO:<$1>" | |
sleep 2 | |
echo "QUIT") | netcat $mailserver 25 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment