[总结]使用 Xinetd 代理 Gmail 的 SMTP 和 IMAP
参考了解: xinted端口转发
Gmail 的 SMTP 和 IMAP 本来一直都是正常的,自从上次无故屏蔽后,虽然后来解封了,但是也变得断断续续了,不稳定。
这里简单分享下用 Linux 下的 Xinetd 代理 SMTP 和 IMAP 收发邮件的方法,原理是使用 Xinetd 进行端口转发,前提你你有一台能正常访问 Gmail 的服务器。
此法针对客户端,Web 端请自己想办法。
安装
以 Ubuntu 14.04.2 为例:
sudo apt-get install -y xinetd创建配置文件 /etc/xinetd.d/gmail,内容如下:
service imap
{
    type = UNLISTED
    port = 993
    bind = 0.0.0.0
    socket_type = stream
    wait = no
    user = nobody
    redirect = imap.gmail.com 993
    per_source = UNLIMITED
    cps = 100 2
}
service smtp-465
{
    type = UNLISTED
    port = 465
    bind = 0.0.0.0
    socket_type = stream
    wait = no
    user = nobody
    redirect = smtp.gmail.com 465
    per_source = UNLIMITED
    cps = 100 2
}
service smtp-587
{
    type = UNLISTED
    port = 587
    bind = 0.0.0.0
    socket_type = stream
    wait = no
    user = nobody
    redirect = smtp.gmail.com 587
    per_source = UNLIMITED
    cps = 100 2
}993对应 IMAP,465和587对应 SMTP,这里没有 POP3 的25端口,需要的自己加上,不过真的不建议用 POP3 了。。。
重启 xinted
sudo service xinetd restart开放防火墙端口:
sudo ufw allow 465
sudo ufw allow 587
sudo ufw allow 993修改本地 hosts 指向你的代理
Linux 和 Mac OS X 在/etc/hosts,Windows 在C:\Windows\System32\drivers\etc\hosts
添加下面的内容,IP 改成你自己的。
xxx.xxx.xxx.xxx smtp.gmail.com
xxx.xxx.xxx.xxx imap.gmail.com测试
发送封邮件试试吧。