File: //opt/setest2
#!/bin/bash
# 1 means we do direct
# 0 means we go mailchannels
# resulting code
# 0 we will skip mailchannels
# 1 we will deliver as no match found go mailchannels
# 2 mx record cannot be resolved to any ips go mailchannels
# 3 ipv6 mx record detected go mailchannels
# 4 mx is ip address go mailchannels
# 5 domain has no MX record but valid ip
IPv6=0
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PATH"
IP1=$(dig +short $1 mx | sort -n)
IP=$(echo -e "$IP1" | awk '{print $2; exit}' | dig +short -f -)
if [[ "$IP" == "" ]]; then
IP=$(echo -e "$IP1" | head -n 1 | dig +short -f -)
fi
if [[ "$IP" == "" ]]; then
echo -e "1 $1" >> /opt/setest2.log
exit 0
fi
FOUND=$(echo -e "$IP" | grepcidr -f /etc/mail/ignore_target_hosts | wc -l)
if [[ "$FOUND" -ge 1 ]]; then
echo -e "0 $1" >> /opt/setest2.log
exit 1
else
echo -e "1 $1" >> /opt/setest2.log
exit 0
fi