背景

最近公司需要将 263 企业邮箱迁移到 office365 上,需要将以前的旧邮件迁移到新邮箱中,方便查看历史记录。但是,迁移的速度非常之慢,经常有迁移失败的。错误如下:

错误: TooManyTransientFailureRetriesPermanentException/RemoteNetworkErrorTransientException/IOException/SocketException: Error: The job encountered too many transient failures ‎(310)‎ and is quitting. The most common failure is RemoteNetworkErrorTransientException/IOException/SocketException with the hit count 60. --> We were unable to reach your email provider. Please check your server settings, or try again later. --> Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. --> A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

看不出来到底是 263 的问题还是 office365 的问题,中间加个代理就方便观察、测试到底哪边的问题了。

关于 imap 的代理,网上实在是太少。踩了几个坑,在此记录下。

测试了以下几个程序:

  1. Nginx,网上文章都说可以代理,但需要单独的用户认证,怎么将用户认证重定向到 263 的用户认证,这个没法搞定。[1][2]
  2. IMAP-Proxy,只有 Python 代码,没有程序。跑了代码有错,没法用。
  3. SquirrelMail imap proxy,这个没找到教程,根本不知道怎么配置。看配置文件中的哪些配置项,尝试配了一些,没法启动成功。
  4. Perdition,这个成功了。

安装

CentOS 7

yum install perdition

Ubuntu

apt install perdition

配置

新建文件 /etc/perdition/perdition.imap4.conf

outgoing_server imap.263.net
log_facility local5
no_lookup
timeout 40
imap_capability "IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA ACL ACL2=UNION STARTTLS"
ssl_mode tls_listen
ssl_cert_file /ca/test.pem
ssl_key_file /ca/test.key

新建文件 /etc/perdition/perdition.imap4s.conf

outgoing_server imap.263.net
log_facility local5
no_lookup
timeout 40
imap_capability "IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA ACL ACL2=UNION STARTTLS"
outgoing_port 143
ssl_mode ssl_listen
ssl_cert_file /ca/test.pem
ssl_key_file /ca/test.key

Ubuntu 需要修改 /etc/default/perdition,将里面的 POP3 和 POP3S 设置成 no。

启动服务

CentOS 7

systemctl restart perdition-imap4
systemctl restart perdition-imap4s

Ubuntu

service perdition restart

  1. nginx 代理imap pop smtp
  2. NGINX as POP/IMAP Reverse Proxy
  3. Perdition imap proxy configuration in Debian

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注