默认使用文件存储信息,如果用mysql,只需修改conf/james-database.properties即可:
database.driverClassName=com.mysql.jdbc.Driver
database.url=jdbc:mysql://localhost:3306/mail?autoReconnect=true&zeroDateTimeBehavior=convertToNull&noAccessToProcedureBodies=true
database.username=root
database.password=****
# Supported adapters are:
# DB2, DERBY, H2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE
vendorAdapter.database=MYSQL
# Use streaming for Blobs
# This is only supported on a limited set of databases atm. You should check if its supported by your DB before enable
# it.
#
# See:
# http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html #7.11. LOB Streaming
#
openjpa.streaming=false
启用conf/smtpserver.conf后,可以
1. 限制邮件大小: <maxmessagesize>10240</maxmessagesize>,限制10M
2. 注释掉: <authorizedAddresses>127.0.0.0/8</authorizedAddresses>,否则外网邮件发布出去;
如果在james服务器前加nginx,那么james接收的到的是本地localhost的邮件,默认对localhost信任,所以所有的邮件都能发。
smtp server
from:http://mail-archives.apache.org/mod_mbox/james-server-user/201201.mbox/<4F04A9A3.3030705@campanell.com>
> When with authRequired=true, James will always ask a username/password > for the SMTP connection (initiated by a mail client or a another SMTP > server). > ...except indeed for the hostname (or IP addresses) listed in the > authorizedAddresses tag. > > You are using the correct syntax, but you should add in the > authorizedAddresses list the exact IP address (or hostname) from which > you are sending the mail. >
第一次测试符合此段描述;
第二次测试,结果是:authRequired=true,只能给本域名的用户发邮件。
------------------------------
ehlo localhost
mail from:<a@b.com>
rcpt to:<a@b.com>
DATA
TO:aa
FROM:bb
SUBJECT:yyyyyyyy
fds
test
.
NOOP
----------------------
James部署结构图:
1. Mysql Server: mail提供邮件存储;
2.James server: smtp 25提供其他smtp发送到本邮箱的邮件(在smtpserver.conf将authRequired=true,防止此服务器沦落为垃圾邮件的中继器);
3. James server: smtp 465, IMAP 995, POP3 993提供邮件客户端的加密连接(ssl证书为认真也可用),同时提供账号管理服务,可以直接调用:james-cli.sh;