Initial checkin

This commit is contained in:
Joe
2017-02-07 12:55:56 -06:00
commit b557c002ae
44 changed files with 15499 additions and 0 deletions

48
checkMail.sh Normal file
View File

@@ -0,0 +1,48 @@
#!/bin/bash
#set -x
testhost=webthink.net
testuser=webmaster@${testhost}
logfile=~/mailqueryfail.log
mail=$1
hostPart=${mail/*@/}
if [ hostPart != "localhost" ]
then host=$(dig +short $hostPart MX | sort -n | head -n1 | cut -d " " -f 2)
if [ -z ${host} ]
then echo -e "{status:'err', error:'Unknown mail host'}"
exit 1
fi
else
host=localhost
fi
result=$((cat << EOE
set timeout 60
spawn nc $host 25
expect "220" {
send "EHLO ${testhost}\r"
expect "250 " {
send "MAIL FROM:<${testuser}>\r"
expect "250" {
send "RCPT TO:<${mail}>\r"
expect "250" {
send "QUIT\r"
} -re \[\n\r\]5.*$ {
exit 1 1
close
}
}}}
EOE
) | expect -f - | grep -e '^5')
if [ -z "${result}" ]
then echo "OK : " $mail >> $logfile
echo -e "{status:'ok'}"
exit 0
else echo $mail ":" $result >> $logfile
echo -e "{status:'err', error:'Unknown User'}"
exit 1
fi