mailhandling

This commit is contained in:
WebMaster
2017-02-08 01:26:29 -05:00
parent fe05bb9c9b
commit c5a0603a1e

View File

@@ -1,10 +1,12 @@
#!/bin/bash #!/bin/bash
#set -x set -x
testhost=webthink.net testhost=webthink.net
testuser=webmaster@${testhost} testuser=webmaster@${testhost}
logfile=./checkMailQueryfail.log # logfile=./checkMailQueryfail.log
#echo -e "{\"status\":\"err\", \"path\":\"`pwd`\"}"
#exit 0
mail=$1 mail=$1
hostPart=${mail/*@/} hostPart=${mail/*@/}
@@ -12,7 +14,8 @@ hostPart=${mail/*@/}
if [ hostPart != "localhost" ] if [ hostPart != "localhost" ]
then host=$(dig +short $hostPart MX | sort -n | head -n1 | cut -d " " -f 2) then host=$(dig +short $hostPart MX | sort -n | head -n1 | cut -d " " -f 2)
if [ -z ${host} ] if [ -z ${host} ]
then echo -e "{\"status\":\"err\", \"error\":\"Unknown mail host.\"}" then echo "`date` - ERR : " $mail ": Unknown Host" >> $logfile
echo -e "{\"status\":\"err\", \"error\":\"Unknown mail host.\"}"
exit 1 exit 1
fi fi
else else