本文图文讲解如何使用Apache James搭建企业邮件服务器,包括解压和docker两个版本,这里用的是目前最新的3.7.4版。
通过官网无法直接下载james-server-app-3.7.4-app.zip的可以到我公众号发送关键字“james”或“s4414”领取整套框架,包括3.6.2版。
搭建过程会遇到数据库问题、DNS解析问题、证书问题、邮件客户端报错等等一系列问题,特别是无法发送外网邮件这个巨坑问题卡我最久了,部分问题如下。
02:34:24.959 [INFO ] o.a.j.d.d.DNSJavaService - Couldn't resolve MX records for domain qq.com.
02:34:24.991 [ERROR] o.a.j.d.d.DNSJavaService - Couldn't resolve IP address for host qq.com.
java.net.UnknownHostException: Invalid address: qq.com
at org.xbill.DNS.Address.getByAddress(Address.java:355)
...
02:34:24.994 [INFO ] o.a.j.t.m.r.d.MailDelivrer - No mail server found for: qq.com
...
04:13:56.211 [ERROR] o.a.j.p.n.BasicChannelUpstreamHandler - Unable to process request
javax.net.ssl.SSLHandshakeException: no cipher suites in common
...
03:21:04.525 [WARN ] o.a.j.i.n.ImapChannelUpstreamHandler - Error while processing imap request
javax.net.ssl.SSLHandshakeException: Client requested protocol TLSv1.1 is not enabled or supported in server context
...
02:05:53.874 [WARN ] o.a.j.i.n.ImapChannelUpstreamHandler - Error while processing imap request
org.jboss.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 474554202f204854545...
...
10:03:15.754 [ERROR] o.a.j.GuiceJamesServer - Fatal error while starting James
nl.altindag.ssl.exception.CertificateParseException: Received an unsupported certificate type
...
00:42:15.747 [ERROR] o.a.j.GuiceJamesServer - Fatal error while starting James
java.lang.IllegalArgumentException: unknown object in getInstance: org.bouncycastle.asn1.ASN1Integer
...
Wrapped by: nl.altindag.ssl.exception.PrivateKeyParseException: org.bouncycastle.openssl.PEMException: problem parsing PRIVATE KEY: java.lang.IllegalArgumentException: unknown object in getInstance: org.bouncycastle.asn1.ASN1Integer
...
19:13:04.314 [ERROR] o.a.j.GuiceJamesServer - Fatal error while starting James
java.security.NoSuchAlgorithmException: PKSC12 KeyStore not available
...
Wrapped by: nl.altindag.ssl.exception.GenericKeyStoreException: java.security.KeyStoreException: PKSC12 not found
...
Requested action not taken: relaying denied.
...
Too many retries failure. Bouncing after 3 retries.
...
There are no DNS entries for the hostname Domain : qq.com. I cannot determine where to send this message.
...
03:28:01.945 [INFO ] o.a.j.t.m.r.d.MailDelivrer - Couldn't connect to host, port: 121.51.19.150, 25; timeout 60000
...
04:01:44.017 [ERROR] o.a.j.d.l.MXHostAddressIterator - Couldn't resolve IP address for discovered host mx3.qq.com..
...
03:48:22.889 [INFO ] o.a.j.t.m.r.d.MailDelivrer - Couldn't connect to host, port: mx1.qq.com, 465; timeout 60000
...
03:48:22.432 [INFO ] o.a.j.t.m.r.d.MailDelivrer - Couldn't connect to host, port: hotmail-com.olc.protection.outlook.com, 465; timeout 60000
...
经过一系列折磨最后效果如下图。
(另外,这篇文章内容超详细,涉及Windows、macOS、Linux、docker等超多有用信息,要不要看自己考虑吧。)
解锁阅读