Aliyun Can't send email

Submitted by ruo on Fri, 04/14/2017 - 20:26

Based on visitor JING's comment, now we can apply to open 25 via this page: https://www.alibabacloud.com/help/faq-detail/56130.htm

>>>>

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

/etc/hosts.conf

Update the hostname from the private IP to 127.0.0.1

 

B edit the

/etc/resolv.conf

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,

ping aspmx.l.google.com

 

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 abused response:

由于国际与国内均对垃圾邮件进行严格管控,我国《互联网信息服务管理办法》、《中国互联网协会反垃圾邮件规范》均对垃圾邮件进行说明与管理规范,为了共同维护良好的网络环境,鉴于服务器25端口被大量垃圾邮件充斥,严重影响广大用户正常使用,经专家讨论,阿里云自即日起新购服务器不再提供25端口邮件服务

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. Best solution: Web API to send email on Aliyun Server

take gmail for example: it provider the WEB API to replace SMTP port:

https://developers.google.com/gmail/api/ 

sendgrid and mailgun is also recommend. 

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.