Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.