Here's why http://bybyron.net/php/tools/dns_records.php?domain=smtp.yandex.com&rec=A I whitelisted the result of typing 'ping -c 1 smtp.yandex.com' but since there are five A records that means your script will work about 20% of the time. Now that all 5 IPs are whitelisted it should work 100% of the time.