Skip to content

Instantly share code, notes, and snippets.

@thonixx
Created August 25, 2013 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thonixx/6334628 to your computer and use it in GitHub Desktop.
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)
# 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