本文目录
一、安装
环境:linux-centos7.6
1. 安装JDK(前置)
yum search java-11-openjdk
yum install -y java-11-openjdk
which java
lrwxrwxrwx. 1 root root 22 10月 29 23:27 /usr/bin/java -> /etc/alternatives/java
ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 62 10月 29 23:27 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el7_8.x86_64/bin/java
修改etc/profile,配置环境变量,黄色部分即为JDK位置
2. 安装James
下载:
wget https://www.apache.org/dyn/closer.lua/james/server/james-server-app-3.1.0-app.zip https://downloads.apache.org/james/server/3.5.0/james-server-app-3.5.0-app.zip
解压:
uzip
二、配置
1. 配置Domain
- 修改/config/domainlist.xml
<?xml version="1.0"?>
<!-- JPA implementation for DomainList -->
<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
<autodetect>false</autodetect>
<autodetectIP>false</autodetectIP>
<defaultDomain>develop.com</defaultDomain>
<domainnames>
<domainname>develop1.com</domainname>
<domainname>develop2.com</domainname>
</domainnames>
</domainlist>
<!-- XML based implementation for DomainList -->
<!--<domainlist class="org.apache.james.domainlist.xml.XMLDomainList">
</domainlist> -->
- 将你自定义的域名加入到 /etc/hosts中
2. 将默认的DERBY存储改为Mysql存储
- 将驱动 jar 包(如:mysql-connector-java-8.0.22.jar)添加到 conf/lib 下。
下载:wget https://jorian-space-01.oss-cn-beijing.aliyuncs.com/mysql-connector-java-8.0.22.jar - 修改conf/james-database.properties ,注释掉 默认的 DERBY 存储,改为使用 mysql,记得创建表,否则启动时会报错找不到表
## Use derby as default
#database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
#database.url=jdbc:derby:../var/store/derby;create=true
#database.username=app
#database.password=app
#use mysql store
database.driverClassName=com.mysql.jdbc.Driver
database.url=jdbc:mysql://192.168.1.140:3306/james?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf8
database.username=root
database.password=root
# 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
# Validate the data source before using it
# datasource.testOnBorrow=true
# datasource.validationQueryTimeoutSec=2
# This is different per database. See https://stackoverflow.com/questions/10684244/dbcp-validationquery-for-different-databases#10684260
datasource.validationQuery=select 1
-
修改mailetcontainer.xml,
postmaster 修改为管理员邮箱,可以为 postmaster@yourDomain
-
repositoryPath 同时存在文件存储 (file://)、数据库存储 (db://) 的,将默认的文件存储注释掉,并释放数据库存储;对于只存在文件存储的,不进行释放
-
RemoteAddrNotInNetwork 所在节点注释掉
完整配置如下:
<?xml version="1.0"?>
<mailetcontainer enableJmx="true">
<!-- MailAddress used for PostMaster -->
<context>
<postmaster>postmaster@develop.com</postmaster>
</context>
<!-- Number of spool threads -->
<spooler>
<threads>20</threads>
</spooler>
<processors>
<!-- The root processor is a required processor - James routes all mail on the spool -->
<!-- through this processor first. -->
<!-- -->
<!-- This configuration is a sample configuration for the root processor. -->
<processor state="root" enableJmx="true">
<!-- This mailet redirects mail for the user 'postmaster' at any local domain to -->
<!-- the postmaster address specified for the server. The postmaster address -->
<!-- is required by rfc822. Do not remove this mailet unless you are meeting -->
<!-- this requirement through other means -->
<mailet match="All" class="PostmasterAlias"/>
<!-- Important check to avoid looping -->
<mailet match="RelayLimit=30" class="Null"/>
<!-- The WithPriority mailet allows to set a priority attribute on the mail. If the
attribute is set and priority handling is enabled it will take care of moving the
Mails with higher priority to the head of the queue (so the mails are faster handled). -->
<!--
<mailet match="All" class="WithPriority">
<priority>8</priority>
</mailet>
-->
<!-- Using the following three matchers you can control the mail processing flow based
on the priority attribute. Note that if a mail's priority is set to 8, then all of
the below will match. -->
<!--
<mailet match="HasPriority=8" class="Null"/>
<mailet match="AtLeastPriority=8" class="Null"/>
<mailet match="AtMostPriority=8" class="Null"/>
-->
<!-- Check attachment extensions for possible viruses -->
<!-- The "-z" option requests the check to be non-recursively applied -->
<!-- to the contents of any attached '*.zip' file. -->
<!--
<mailet match="AttachmentFileNameIs=-d -z *.exe *.com *.bat *.cmd *.pif *.scr *.vbs *.avi *.mp3 *.mpeg *.shs" class="Bounce" onMatchException="error">
<inline>heads</inline>
<attachment>none</attachment>
<passThrough>false</passThrough>
<prefix>[REJECTED]</prefix>
<notice>
The Security Policy of XXX does not allow to forward messages containing attachments having any of the extensions .exe, .com, .bat, .cmd, .pif, .scr, .vbs, .avi, .mp3, .mpeg, .shs, therefore your message has been rejected.
Please don't reply to this e-mail as it has been automatically sent by the antivirus system.
Regards, Postmaster XXX.YYY
.....................................
</notice>
</mailet>
-->
<!-- sample SMIME mailets configuration -->
<!--
<mailet match="IsSMIMEEncrypted" class="SMIMEDecrypt">
<keyStoreType>pkcs12</keyStoreType>
<keyStoreFileName>c:/path.pfx</keyStoreFileName>
<keyStorePassword>myKeyStorePass</keyStorePassword>
<keyAlias>myKeyAlias</keyAlias>
<keyAliasPassword>myKeyPass</keyAliasPassword>
</mailet>
<mailet match="IsSMIMESigned" class="SMIMECheckSignature">
<keyStoreType>pkcs12</keyStoreType>
<keyStoreFileName>c:/path.pfx</keyStoreFileName>
<keyStorePassword>myKeyStorePass</keyStorePassword>
<strip>false</strip>
<onlyTrusted>true</onlyTrusted>
</mailet>
-->
<!-- Anti-spam processing -->
<!-- The following two entries avoid double anti-spam analysis -->
<!-- for forwarded messages. -->
<!-- Has spam checking already been done? -->
<mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
<processor>transport</processor>
</mailet>
<!-- Spam checking will not be done twice -->
<mailet match="All" class="SetMailAttribute">
<spamChecked>true</spamChecked>
</mailet>
<!-- White List:
If you use block lists, you will probably want to check
for known permitted senders. This is particularly true
if you use more aggressive block lists, such as SPEWS,
that are prone to block entire subnets without regard
for non-spamming senders.
-->
<!-- Messages from authenticated senders never are spam -->
<mailet match="SMTPAuthSuccessful" class="ToProcessor">
<processor>transport</processor>
</mailet>
<!-- Messages signed by trusted users never are spam -->