1、服务器安装
- 从官网下载邮箱服务器压缩文件,本案例使用版本为:apache-james-3.0-beta4;
- 将压缩文件减压到无空格、无中文的路径下;
- 将 jaxb-impl-2.1.3.jar 复制到:安装目录\conf\lib 文件夹下,若不将这个 jar 包复制到该文件夹下,启动服务器时会出现异常,如下:
F:\JavaFiles\apache-james-3.0-beta4\bin>run.bat
INFO 21:33:30,162 | org.apache.james.container.spring.context.JamesServerApplicationContext | Refreshing org.apache.james.container.spring.context.JamesServerApplicationContext@2096442d: startup date [Mon Nov 18 21:33:30 CST 2019]; root of context hierarchy
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Failed to create the JAXB binder; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
类的两个属性具有相同名称 "outputs"
this problem is related to the following location:
at public java.util.List org.apache.camel.model.ResequenceDefinition.getOutputs()
at org.apache.camel.model.ResequenceDefinition
this problem is related to the following location:
at private java.util.List org.apache.camel.model.ResequenceDefinition.outputs
at org.apache.camel.model.ResequenceDefinition
- with linked exception:
[com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
类的两个属性具有相同名称 "outputs"
......
- 服务器默认使用的是 DERBY 数据库,我们将其更改为 MySQL 数据库,具体如下:
- 将 MySQL 连接驱动 jar 包(mysql-connector-java-5.1.48.jar)复制到:安装目录\conf\lib 文件夹下;
- 修改配置文件,具体如下:
2、启动服务器
在 bin 文件下,使用 cmd 命令打开命令窗口,使用命令:run.bat 启动服务器,当出现如下画面时即启动成功。
F:\JavaFiles\apache-james-3.0-beta4\bin>run.bat
INFO 21:35:19,833 | org.apache.james.container.spring.context.JamesServerApplicationContext | Refreshing org.apache.james.container.spring.context.JamesServerApplicationContext@61dc03ce: startup date [Mon Nov 18 21:35:19 CST 2019]; root of context hierarchy
log4j:WARN No appenders could be found for logger (org.apache.commons.configuration.ConfigurationUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
INFO 21:35:20,547 | org.apache.james.container.spring.context.JamesServerApplicationContext | Bean 'logprovider' of type [class org.apache.james.container.spring.lifecycle.LogProviderImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO 21:35:20,878 | james.mailrepositorystore | JamesMailStore init...
......
INFO 21:35:23,100 | james.imapserver | Init IMAP Service done
INFO 21:35:25,250 | org.apache.james.app.spring.JamesAppSpringMain | Apache James Server is successfully started in 5475 milliseconds.
启动服务器的同时,在指定数据库中创建 9 张表,如下:
3、创建域名和添加用户
3.1 创建域名
开启服务器的 cmd 命令窗口不能关闭,并新开启一个命令窗口,输入命令:james-cli.bat -h 主机名 -p 端口号 adddomain 邮箱域名,例如:james-cli.bat -h localhost -p 9999 adddomain test.com
此时会在表:james_domain 中添加一条数据,如下:
3.2 添加用户
在新开启的命令窗口中输入命令:james-cli.bat -h 主机名 -p 端口号 adduser 邮箱地址 密码,例如:james-cli.bat -h localhost -p 9999 adduser admin@test.com admin,此时会在表:james_user 中添加一条数据,如下:
4、邮箱客户端
邮箱客户端使用 Foxmail ,配置如下:
注:接收服务器类型要选择:POP3
注:若点击创建无法完成,可以重新启动服务器
添加新用户:
此时可以两个账号互相发邮件测试了。