One of our client running their Magento site in Aliyun HongKong, the site in Aliyun can't send email out.
Tech debug workflow:
1, login Cpanel > Email > Track Delivery.
The logs show that. all the emails send to this server are success, and send to other domains shows connect time out. it should be some internet issues of problem.
2, to make sure, we login SSH and directly send the email
php -r "mail([email protected]', 'test subject', 'test body', 'From: Andre Matos
no error output, go back to Cpanel > Email > Track Delivery show that email was error.
use the command
exigrep [email protected] /var/log/exim_mainlog
We get more details, it should can't connect to gmail email server.
3, we can 100% sure it's a internet issue, not the PHP.
and as we know, the Aliyun always has some strange setting in their server. like their eth0 is the private network IP, not the public IP. their rpm source is use their own server and always lack some import packages.
The solution is
A edit the
Update the hostname from the private IP to 127.0.0.1
B edit the
use Google DNS to replace Aliyun's DNS
4. After update the network, We try email again, but still failed.
We think the network should work now, but after input the mail command, some error, no email can send out. check the email log file, it still said Gmail server can't connected.
Ping the gmail server, it can get response,
But telnet the 25 port, it can nothing,
telnet aspmx.l.google.com 25
Interesting, the email port 25 is blocked, we double check the firewall in the server, can make sure it's not the issues on the server, and must be the Aliyun Block the email port.
5. Submit Ticket to Aliyun
We have to submit ticket to Aliyun to ask them open the 25 port. But get an absurd response:
Simply, they said based on some laws in China, to prevent the spam emails, they blocked the 25 port.
I never see a VPS/Server blocked port by the ISP before, this is the first time. waste the time of our team and our clients.
6. Our solution
If you are running site in Aliyun, and need email server for your customers.
We provided the email accounts to avoid this problem, you can buy the email account with your domain in our site and setup SMTP in your site script.
The business email is start only $0.36
And if you need larger email, it start at $1.79 for 25Gb
Gmail is blocked in China, and if you use the email outboard, G-suite is the best choice. we provided the cheaper price then office.