使用Xinetd服务创建的SMTP和IMAP代理访问Gmail

由于一些不明真相的原因,所以Gmail一直就访问不了,这里提供一个简单的方法可以让电脑来接收gmail的邮件。

Xinetd介绍

xinetd提供类似于inetd+tcp_wrapper的功能,但是更加强大和安全。我们这里只用到了xinetd的端口转发功能。

安装

找一台vpn,建议香港,日本,访问速度快。我用的是centos,所以已centos为例。

1
2
3
4
#安装
yum install -y xinetd
#编辑配置文件
vim /etc/xinetd.d/gmail

配置文件的内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
}
1
2
#重启服务
service xinetd restart

搞定,可以telnet确认下端口,如果开了防火墙需要把防火墙关了或者开放993,587和465这三个端口。

这样在gmail设置的时候把smtp.gmail.com,imap.gmail.com这两个地址替换成vpn的ip就可以了。

最后

参考地址:https://www.v2ex.com/t/182720

nginx也可以用来做代理,在编译的时候需要加上参数-with-mail --with-mail_ssl_module,但是配置好象稍复杂,官方文档这里:https://www.nginx.com/resources/admin-guide/mail-proxy/ 有兴趣的自己看吧,反正xinetd目前测试可以。