文档章节

Apache James简单邮件服务器配置

抢小孩糖吃
 抢小孩糖吃
发布于 2016/09/13 14:54
字数 2152
阅读 244
收藏 1

#编者注 之前的老系统使用的是windows上的hmail服务器,由于界面感官好,配置迅速,则为了上线使用。但度过了3年左右,原始配置hmail的人员离职。并且由于Windows的问题,并不能够和Linux系统上的软件打包。并且,由于近期断电事故导致风险加剧。所以,需要搭建简单易用的Mail服务器。

#Apache James Apache James项目提供了一组丰富的开放源代码的模块和库,由Java编写,互联网邮件通信建设成为先进的企业邮件服务器相关。

#下载James

#JAVA_HOME [20161102]由于本人第二次的是使用的是mac系统,安装的JDK8,James找不到JAVA_HOME。需要在James当中添加。 ##JAVA_HOME添加到run.sh - 失败 由于James通过bin/run.sh运行,首先尝试的是在run.sh中添加JAVA_HOME,如下内容是在run.sh头部进行添加

# -- zhanpeng for mac config JAVA_HOME--
JAVA_HOME=`/usr/libexec/java_home`
echo $JAVA_HOME

运行结果

vfxdeiMac:bin zhanpeng$ ./run.sh 
/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
ERROR: JAVA_HOME not found in your environment.

Please, set the JAVA_HOME variable in your environment to match the
location of the Java Virtual Machine you want to use.

确认,实际的James的执行是使用phoenix.sh进行执行 ##JAVA_HOME添加到phoenix.sh 在bin/phoenix.sh添加JAVA_HOME

# -- zhanpeng for mac config JAVA_HOME--
JAVA_HOME=`/usr/libexec/java_home`

运行结果

vfxdeiMac:bin zhanpeng$ ./run.sh 
/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
Using PHOENIX_HOME:   /Users/zhanpeng/build/james/james-2.3.2.1
Using PHOENIX_TMPDIR: /Users/zhanpeng/build/james/james-2.3.2.1/temp
Using JAVA_HOME:      /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
Running Phoenix: 

Phoenix 4.2

James Mail Server 2.3.2.1
Remote Manager Service started plain:4555

#Component named "pop3server" failed to pass through the Starting stage Mac和Ubuntu系统限制普通用户使用1024以下的端口,使用管理员权限运行,就不会发生问题

sudo ./run.sh

#修改James User配置为JDBC **注意:**如下内容在第一次运行james之后才会出现,James使用的是DBCP连接池,默认配置支持Apache Derby、MySQL、MSSQL、HypersonicSQL,查看conf/sqlResources.xml还支持其他数据库。请自行查看 ##修改repository 修改配置文件james-2.3.2.1/apps/james/SAR-INF/config.xml,这里我们需要注意,把文件类型的repository注释掉,替换成数据库repository

<!--
      <repository name="LocalUsers" class="org.apache.james.userrepository.UsersFileRepository">
         <destination URL="jdbc:sqlite://D:/users.sqlite"/>
      </repository>
	  -->

      <!-- Database backed user repositories -->
      <!-- -->
      <!-- Use these configurations to store user info in a database. -->
      <!-- Note: The <data-source> element must refer to a connection configured -->
      <!--       in the <database-connections> configuration section. -->

      <!-- The LocalUsers repository, for storing James' User info. -->
      <repository name="LocalUsers" class="org.apache.james.userrepository.JamesUsersJdbcRepository" destinationURL="db://maildb/users">
         <sqlFile>file://conf/sqlResources.xml</sqlFile>
      </repository>

##JDBC配置 取消注释,并按照jdbc url的格式配置

      <!-- JDBC driver .jar libraries for other RDBMS can be placed in ~james/lib/  -->

      <!-- You can download latest Connector/J from   -->
      <!-- http://dev.mysql.com/downloads/connector/j/3.1.html -->
      <!-- -->
      <!-- Example, connecting to a MySQL database called "mail" on localhost-->
      <!-- -->
      <!-- The max value is the maximum number of concurrent connections James will -->
      <!-- open to this database-->
      <!-- If you see "SQLException: Giving up... no connections available." in your -->
      <!-- log files or bounced mail you should increase this value -->

      <data-source name="maildb" class="org.apache.james.util.dbcp.JdbcDataSource">
         <driver>com.mysql.jdbc.Driver</driver>
         <dburl>jdbc:mysql://192.168.1.200/james_user?autoReconnect=true</dburl>
         <user>username</user>
         <password>password</password>
         <max>20</max>
      </data-source>

##添加JDBC驱动到lib 由于编者链接的MySQL兼容mysql-connector-java-5.1.40.jar
添加mysql-connector-java-5.1.40.jarjames-2.3.2.1/lib目录,jdbc驱动程序可以去mvnrepo网站下载。

##输出

vfxdeiMac:bin zhanpeng$ sudo ./run.sh 
/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
Using PHOENIX_HOME:   /Users/zhanpeng/build/james/james-2.3.2.1
Using PHOENIX_TMPDIR: /Users/zhanpeng/build/james/james-2.3.2.1/temp
Using JAVA_HOME:      /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
Running Phoenix: 

Phoenix 4.2

James Mail Server 2.3.2.1
Remote Manager Service started plain:4555
POP3 Service started plain:110
SMTP Service started plain:25
NNTP Service started plain:119
FetchMail Disabled

##数据库工具查看 James的用户内容,在数据库当中创建了

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `username` varchar(64) NOT NULL,
  `pwdHash` varchar(50) DEFAULT NULL,
  `pwdAlgorithm` varchar(20) DEFAULT NULL,
  `useForwarding` smallint(6) DEFAULT NULL,
  `forwardDestination` varchar(255) DEFAULT NULL,
  `useAlias` smallint(6) DEFAULT NULL,
  `alias` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

#修改James Inbox配置为JDBC

<!-- The inbox repository is the location for users inboxes -->
      <!-- Default setting: file based repository - enter path ( use  "file:///" for absolute) -->
<!--
      <inboxRepository>
         <repository destinationURL="file://var/mail/inboxes/" type="MAIL"/>
      </inboxRepository>
-->

      <!-- Alternative inbox repository definition for DB use. -->
      <!-- The format for the destinationURL is "db://<data-source>/<table>" -->
      <!-- <data-source> is the datasource name set up in the database-connections block, below -->
      <!-- <table> is the name of the table to store user inboxes in -->
      <!-- The user name is used as <repositoryName> for this repository config. -->
      
      <inboxRepository>
         <repository destinationURL="db://maildb/inbox/" type="MAIL"/>
      </inboxRepository>
      

      <!-- Alternative inbox repository definition for DB use. -->
      <!-- Stores message body in file system, rest in database -->
      <!--
      <inboxRepository>
         <repository destinationURL="dbfile://maildb/inbox/" type="MAIL"/>
      </inboxRepository>
      -->

      <!-- Alternative inbox repository definition for mbox use. -->
      <!-- This method uses UNIX standard mbox files and is meant for people using mbox files -->
      <!-- with systems such as mail list archive displayers -->
      <!-- Note that dot-locking is not currently supported -->
      <!-- so network (write) accesses may cause mbox corruption -->
      <!-- the sample mbox URL is an absolute URL; mbox:///var/mail will put the users mbox files in /var/mail/-->
      <!--
      <inboxRepository>
         <repository destinationURL="mbox:///var/mail/" type="MAIL"/>
      </inboxRepository>
      -->

inbox表结构

DROP TABLE IF EXISTS `inbox`;
CREATE TABLE `inbox` (
  `message_name` varchar(200) NOT NULL,
  `repository_name` varchar(100) NOT NULL,
  `message_state` varchar(30) NOT NULL,
  `error_message` varchar(200) DEFAULT NULL,
  `sender` varchar(255) DEFAULT NULL,
  `recipients` text NOT NULL,
  `remote_host` varchar(255) NOT NULL,
  `remote_addr` varchar(20) NOT NULL,
  `message_body` longblob NOT NULL,
  `message_attributes` longblob,
  `last_updated` datetime NOT NULL,
  PRIMARY KEY (`repository_name`,`message_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

#修改James Spool配置为JDBC Spool repository是收到的邮件临时存储的本地位置

<!-- Spool repository configuration -->
   <!-- The spool repository is the location where incoming mails are temporarily stored -->
   <!-- before being processed. -->
   <!--
   <spoolrepository destinationURL="file://var/mail/spool/" type="SPOOL"/>
   -->

   <!-- Alternative spool repository definition for JDBC use -->
   
   <spoolrepository destinationURL="db://maildb/spool/spool" type="SPOOL"/>
   

   <!-- Alternative spool repository definition for JDBC use -->
   <!-- Stores message body in file system, rest in database -->
   <!--
   <spoolrepository destinationURL="dbfile://maildb/spool/spool" type="SPOOL"/>
   -->

数据库表结构

DROP TABLE IF EXISTS `spool`;
CREATE TABLE `spool` (
  `message_name` varchar(200) NOT NULL,
  `repository_name` varchar(100) NOT NULL,
  `message_state` varchar(30) NOT NULL,
  `error_message` varchar(200) DEFAULT NULL,
  `sender` varchar(255) DEFAULT NULL,
  `recipients` text NOT NULL,
  `remote_host` varchar(255) NOT NULL,
  `remote_addr` varchar(20) NOT NULL,
  `message_body` longblob NOT NULL,
  `message_attributes` longblob,
  `last_updated` datetime NOT NULL,
  PRIMARY KEY (`repository_name`,`message_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

#查看并修改James远程管理的用户名密码 查看配置文件,可以看到如下内容,请修改管理密码

   <!-- The RemoteManager server is enabled by default -->
   <!-- Disabling blocks will stop them from listening, -->
   <!-- but does not free as many resources as removing them would -->
   <remotemanager enabled="true">
      <port>4555</port>
      <!--  Uncomment this if you want to bind to a specific inetaddress -->
      <!--
      <bind> </bind>
      -->
      <!--  Uncomment this if you want to use TLS (SSL) on this port -->
      <!--
      <useTLS>true</useTLS>
      -->
      <handler>
         <!-- This is the name used by the server to identify itself in the RemoteManager -->
         <!-- protocol.  If autodetect is TRUE, the server will discover its -->
         <!-- own host name and use that in the protocol.  If discovery fails, -->
         <!-- the value of 'localhost' is used.  If autodetect is FALSE, James -->
         <!-- will use the specified value. -->
         <helloName autodetect="true">myMailServer</helloName>
         <administrator_accounts>
<!-- CHECKME! -->
            <!-- Change the default login/password. -->
            <account login="root" password="!changeme!"/>
         </administrator_accounts>
         <connectiontimeout> 60000 </connectiontimeout>
         <!-- The prompt directive adds a prompt to every output from RemoteManager -->
         <!-- 
         <prompt>james&gt;</prompt>
         -->
      </handler>
   </remotemanager>

#telnet登录并添加用户

vfxdeiMac:SAR-INF zhanpeng$ telnet localhost 4555
Trying ::1...
Connected to localhost.
Escape character is '^]'.
JAMES Remote Administration Tool 2.3.2.1
Please enter your login and password
Login id:
root
Password:
!changeme!
Welcome root. HELP for a list of commands
help
Currently implemented commands:
help                                    display this help
listusers                               display existing accounts
countusers                              display the number of existing accounts
adduser [username] [password]           add a new user
verify [username]                       verify if specified user exist
deluser [username]                      delete existing user
setpassword [username] [password]       sets a user's password
setalias [user] [alias]                 locally forwards all email for 'user' to 'alias'
showalias [username]                    shows a user's current email alias
unsetalias [user]                       unsets an alias for 'user'
setforwarding [username] [emailaddress] forwards a user's email to another email address
showforwarding [username]               shows a user's current email forwarding
unsetforwarding [username]              removes a forward
user [repositoryname]                   change to another user repository
shutdown                                kills the current JVM (convenient when James is run as a daemon)
quit                                    close connection

adduser wangyinghan 123
User wangyinghan added

#使用thunderbird链接 异常提示

接收:POP3,xxx,未加密
发送:SMTP,xxx,未加密
用户名:xxx

查询James文档,得知需要修改useTLS值为ssl POP3

<pop3server enabled="true">
      <!-- port 995 is the well-known/IANA registered port for POP3S  ie over SSL/TLS -->
      <!-- port 110 is the well-known/IANA registered port for Standard POP3 -->
      <port>110</port>

      <!-- Uncomment this if you want to bind to a specific inetaddress -->
      <!--
      <bind> </bind>
      -->
      <!--  Uncomment this if you want to use TLS (SSL) on this port -->
      
      <useTLS>true</useTLS>
      

      <handler>
         <!-- This is the name used by the server to identify itself in the POP3 -->
         <!-- protocol.  If autodetect is TRUE, the server will discover its -->
         <!-- own host name and use that in the protocol.  If discovery fails, -->
         <!-- the value of 'localhost' is used.  If autodetect is FALSE, James -->
         <!-- will use the specified value. -->
         <helloName autodetect="true">myMailServer</helloName>
         <connectiontimeout>120000</connectiontimeout>
      </handler>
   </pop3server>

SMTP

<smtpserver enabled="true">
      <!-- port 25 is the well-known/IANA registered port for SMTP -->
      <port>25</port>

      <!-- Uncomment this if you want to bind to a specific inetaddress -->
      <!-- Please NOTE: you should add this IP also to your RemoteAddrNotInNetwork -->
      <!-- in order to avoid relay check for locallly generated bounces -->
      <!--
      <bind> </bind>
      -->
      <!-- Uncomment this if you want to use TLS (SSL) on this port -->
      
      <useTLS>true</useTLS>

RemoteManager

<remotemanager enabled="true">
      <port>4555</port>
      <!--  Uncomment this if you want to bind to a specific inetaddress -->
      <!--
      <bind> </bind>
      -->
      <!--  Uncomment this if you want to use TLS (SSL) on this port -->
      
      <useTLS>true</useTLS>

##问题 - 无法启动 查找文档需要安装ssl,并和http服务器去链接,超出范围。暂时不链接

#关于邮件收发的测试 ##未修改 - localhost A在本机登录A@localhost 登录正常
A@localhost 发送给 A@localhost 收发正常
B在外机登录B@locahost 不能登录
B在外机登录B@A_IP 登录征程
B@A_IP 发送给 A@localhost 收发正常 - 但是无法修改成B@localhost

##localhost修改为IP A在本机登录A@localhost 登录正常
A在本机登录A@IP 登陆正常
B在外机登录B@IP 登陆正常
A收发正常
B收发正常

© 著作权归作者所有

抢小孩糖吃

抢小孩糖吃

粉丝 70
博文 244
码字总数 235322
作品 0
东城
程序员
私信 提问
Apache基金会 - 软件介绍

编者注 大家开发应用了很多Apache基金会的内容,如Java的Tomcat,Apache HTTP Server,Hadoop等。但是没有完整的总结。一直想把Apache Commons进行学习,索性简单看下Apache基金会都有什么项...

抢小孩糖吃
2016/11/02
5
0
James邮箱服务器简单运行配置

James简单运行配置 James:Java Apache Mail Enterprise Server 是一个企业级的JAVA邮件服务器.开源的. 一.配置; 首先将james-binary-2.3.1.zip解压缩下载到你的安装目录。 我们可以把这个过程...

lyle_luo
2018/10/18
0
0
Java邮件服务器--James

Apache James(Java Apache Mail Enterprise Server)是Apache组织的子项目之一,完全采用纯Java技术开发,实现了SMTP、POP3与NNTP等多种邮件相关协议。 James也是一个邮件应用平台,可以通过...

匿名
2008/09/11
28K
2
Apache James Server 3.0-beta4 发布

Apache James Server 3.0-beta4 发布,Apache James Server 3.0 和 2.3.2 集成了邮件服务器,包括了高级完整的功能特性。Apache James Server 3.0 提供一个 mailet 容器,是基于 Spring 构建...

chaun
2014/07/10
1K
2
James 3.0-M1 发布,Java邮件服务器

Apache James(Java Apache Mail Enterprise Server)是Apache组织的子项目之一,完全采用纯Java技术开发,实现了SMTP、POP3与NNTP等多种邮件相关协议。 James也是一个邮件应用平台,可以通过...

红薯
2010/11/01
979
1

没有更多内容

加载失败,请刷新页面

加载更多

阿里云POLARDB如何助力轻松筹打造5亿用户信赖的大病筹款平台?

轻松筹首创了“大病救助”模式,帮助了众多病患在第一时间解決了医疗资金等问题,为了从源头解决了医疗资金问题。而在轻松筹这样全球5.5亿用户信赖的大病筹款平台的背后,是日益增长的各种数...

阿里云云栖社区
4分钟前
1
0
Confluence 6 在升级过程中查看合并日志

为了监控升级的过程,你应该查看 application log 日志中的输出。 通常日志经常将会显示多个日志实例,这个实例是定义在日志的 INFO 级别的,通常格式如下: WikiToXhtmlMigrationThread-n -...

honeymoose
4分钟前
0
0
git diff 文件对比

git diff filepath 工作区与暂存区比较 git diff HEAD filepath 工作区与HEAD ( 当前工作分支) 比较 git diff --staged 或 --cached filepath 暂存区与HEAD比较 git diff branchName filepa......

李佳顺
4分钟前
0
0
spring mvc 定制化配置

spring mvc 自定义配置 1.实现某些接口,然后让上面的类加载进去. class MyHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { @Override public boolean......

最爱肉肉
7分钟前
0
0
OSG_采样像机的内容如果不显示到窗口上

cameraLight->setRenderTargetImplementation(Camera::FRAME_BUFFER_OBJECT);// 这句使内容不渲染到屏幕上cameraLight->setRenderOrder(Camera::PRE_RENDER); 1.setRenderTargetImplement......

洛克人杰洛
10分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部