Improving Zoho Mail's Sending and Receiving Speed with Nginx Port Forwarding

Publish: 2019-05-22 | Modify: 2019-05-22

Zoho Mail is a foreign email service provider that offers free and paid email services. They recently launched the "MAIL LITE" package, starting at just $1/month, which supports unlimited email aliases (only available in the paid package). It is a great choice for personal website owners. However, Zoho Mail's mail servers are located in the United States, resulting in a latency of up to 300ms in China, which is quite slow.

Zoho Mail

In a previous article, "Using Nginx for TCP/UDP Port Forwarding," I shared how to use Nginx for port forwarding to improve poor direct network connections. Here, we will use Nginx port forwarding to accelerate Zoho Mail's sending and receiving.

Suitable Scenarios for Port Forwarding

Port forwarding is suitable when the speed is poor or packet loss is severe when directly connecting to a service. I have created a simple flowchart below using ProcessOn.

Port Forwarding

Preparation

Add Configuration Files

Add the following configuration in nginx.conf:

stream {
    # Forward port 465 of the Bandwagon VPS to smtp.zoho.com
    server {
        listen 465;
        proxy_connect_timeout 5s;
        proxy_timeout 20s;
        proxy_pass smtp.zoho.com:465;
    }
    # Forward port 993 of the Bandwagon VPS to imap.zoho.com
    server {
        listen 993;
        proxy_connect_timeout 5s;
        proxy_timeout 20s;
        proxy_pass imap.zoho.com:993;
    }
}

After modifying the file, test the configuration with nginx -t to ensure it is correct. Then, reload Nginx for the changes to take effect (nginx -s reload). Also, make sure to allow ports 465 and 993 in the firewall.

  • smtp.zoho.com: Zoho Mail's SMTP address
  • imap.zoho.com: Zoho Mail's IMAP address

Finally, when configuring your email client, use the IP address of the Bandwagon VPS instead of Zoho Mail's connection address. This will act as a relay.

Summary

Port forwarding has a wide range of applications and can be used in scenarios with poor network connections or traffic filtering. The above method can also be used to forward other email services or accelerate other businesses. The underlying principle is the same - using an additional server for traffic forwarding.

In addition, Nginx provides a dedicated mail module for email proxying. However, I have not studied the implementation details, so I cannot say which method is more effective.


Comments