Preface: I only got as far as using james to send email; I never tested receiving mail.
There is plenty of material online — search around if you’re interested. I too gathered material from the web, tried things out, thought it over, and then wrote this article, which quotes some of that material. No waffle, let’s get to work~
Prerequisites:
- Because the Apache James mail service needs ports below 1024, log in as root to deploy it
- Install JDK 1.5 or later first; before deploying, make sure your JDK environment variables such as JAVA_HOME are already set
- When James starts, its SMTP service listens on port 25 by default, POP3 on port 110, and NNTP on port 119, so make sure these ports are not occupied. Under Linux, the command to check whether a port is occupied is: lsof -i:port number, for example:
means port 25 is occupied by sendmail (the default mail service under linux)
Shutting down the SendMail service: RedHat systems generally have the sendmail mail service installed by default, so when deploying ApacheJames you need to shut sendmail down. You can disable sendmail in the following ways, which also keep it from starting up again automatically when the system reboots. a) Check sendmail's status with the chkconfig --list sendmail command 
b) Disable sendmail's startup with the chkconfig sendmail off command chkconfig sendmail off
c) Now running chkconfig --list sendmail again shows that every startup level for sendmail has been turned off 
The actual deployment:
Unpack the Apache James package (apache-james-2.3.2.tar.gz):
tar zxvf apache-james-2.3.2.tar.gzAfter unpacking, you’ll have an extra directory, james-2.3.2
Go into the james-2.3.2/bin directory and run run.sh to generate james’s configuration file config.xml
sh run.shrun.sh: line 37: /usr/local/james-2.3.2/bin/phoenix.sh: permission denied
Permission denied (the unpacked run.sh file probably wasn’t given execute permission). You can run the following command:
chmod +x run.shThen run the run.sh command again:
sh run.shUsing PHOENIX_HOME: /usr/local/james-2.3.2
Using PHOENIX_TMPDIR: /usr/local/james-2.3.2/temp
Using JAVA_HOME: /usr/java/jdk1.5.0
Running Phoenix:
Phoenix 4.2
James Mail Server 2.3.2
Remote Manager Service started plain:4555
POP3 Service started plain:110
SMTP Service started plain:25
NNTP Service started plain:119
FetchMail Disabled
This means James started successfully.
Press Ctrl + C to quit James and edit the config.xml file.
The generated config.xml is placed under ../james-2.3.2/apps/james/SAR- INF
There are many ways to modify it.
The main spots are:
Postmaster@your-mail-server-domain.com Here, "your-mail-server-domain.com" is what others see as the sender when they receive mail. At the same time, add 127.0.0.1 your [mail server](http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Emyexception%2Ecn%2Fapache%2F1468802%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=wangyuead_cpr&k=%D3%CA%BC%FE%B7%FE%CE%F1%C6%F7&k0=%D3%CA%BC%FE%B7%FE%CE%F1%C6%F7&k1=%D3%CA%BC%FE%B7%FE%CE%F1&k2=%CA%FD%BE%DD%BF%E2&k3=james&k4=java&k5=server&sid=8713e2f6e9ed16e4&ch=0&tu=u1828791&jk=ffb1bdeaa3309920&cf=29&fv=15&stid=9&urlid=0&luki=1&seller_id=1&di=128)'s [domain](http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Emyexception%2Ecn%2Fapache%2F1468802%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=wangyuead_cpr&k=%D3%F2%C3%FB&k0=%D3%F2%C3%FB&k1=%D3%CA%BC%FE&k2=phoenix&k3=linux&k4=%D3%CA%BC%FE%B7%FE%CE%F1%C6%F7&k5=%D3%CA%BC%FE%B7%FE%CE%F1&sid=8713e2f6e9ed16e4&ch=0&tu=u1828791&jk=ffb1bdeaa3309920&cf=29&fv=15&stid=9&urlid=0&luki=7&seller_id=1&di=128).com to /etc/hosts[xml] view plaincopyprint?

<servernames autodetect="true" autodetectIP="true">change to
<servernames autodetect="false" autodetectIP="false">And change the child tags of [server](http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Emyexception%2Ecn%2Fapache%2F1468802%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=wangyuead_cpr&k=server&k0=server&k1=%D3%F2%C3%FB&k2=%D3%CA%BC%FE&k3=phoenix&k4=linux&k5=%D3%CA%BC%FE%B7%FE%CE%F1%C6%F7&sid=8713e2f6e9ed16e4&ch=0&tu=u1828791&jk=ffb1bdeaa3309920&cf=29&fv=15&stid=9&urlid=0&luki=6&seller_id=1&di=128)names to your own domain
[xml] view plaincopyprint?

<<span style="width: auto; height: auto;" id="19_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Emyexception%2Ecn%2Fapache%2F1468802%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3\_hc&q=wangyuead\_cpr&k=server&k0=server&k1=%D3%F2%C3%FB&k2=%D3%CA%BC%FE&k3=phoenix&k4=linux&k5=%D3%CA%BC%FE%B7%FE%CE%F1%C6%F7&sid=8713e2f6e9ed16e4&ch=0&tu=u1828791&jk=ffb1bdeaa3309920&cf=29&fv=15&stid=9&urlid=0&luki=6&seller_id=1&di=128" id="19_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">server</span></a></span>name>your <span style="width: auto; height: auto;" id="20_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Emyexception%2Ecn%2Fapache%2F1468802%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3\_hc&q=wangyuead\_cpr&k=%D3%CA%BC%FE%B7%FE%CE%F1%C6%F7&k0=%D3%CA%BC%FE%B7%FE%CE%F1%C6%F7&k1=%D3%CA%BC%FE%B7%FE%CE%F1&k2=%CA%FD%BE%DD%BF%E2&k3=james&k4=java&k5=server&sid=8713e2f6e9ed16e4&ch=0&tu=u1828791&jk=ffb1bdeaa3309920&cf=29&fv=15&stid=9&urlid=0&luki=1&seller_id=1&di=128" id="20_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">mail server</span></a></span>'s <span style="width: auto; height: auto;" id="21_nwp"><a target=_blank style="text-decoration: none;" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Emyexception%2Ecn%2Fapache%2F1468802%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3\_hc&q=wangyuead\_cpr&k=%D3%F2%C3%FB&k0=%D3%F2%C3%FB&k1=%D3%CA%BC%FE&k2=phoenix&k3=linux&k4=%D3%CA%BC%FE%B7%FE%CE%F1%C6%F7&k5=%D3%CA%BC%FE%B7%FE%CE%F1&sid=8713e2f6e9ed16e4&ch=0&tu=u1828791&jk=ffb1bdeaa3309920&cf=29&fv=15&stid=9&urlid=0&luki=7&seller_id=1&di=128" id="21_nwl"><span style="font-size:14px;color:#0000ff;width:auto;height:auto;float:none;">domain</span></a></span>.com</servername>
Change the storage location of inbox.
Change
Comment it out, or change it to the following, which means using a database for storage instead of files
[xml] view plaincopyprint?
<inboxRepository>
<repository destinationURL="db://maildb/inbox/" type="MAIL"/>
</inboxRepository>
Note: if you change it to the dbfile protocol, that means the mail headers live in the database and the mail bodies live in files
- Comment out the service network segment; enable it if you need validation.
[xml] view plaincopyprint?
<!-- <mailet match="RemoteAddrNotInNetwork=127.0.0.1" class="ToProcessor">
<processor> relay-denied </processor>
<notice>550 - Requested action not taken: relaying denied</notice>
</mailet> -->

Change outgoing’s storage to a database
Change
<mailet match="All" class="RemoteDelivery"> <outgoing> file://var/mail/outgoing/ </outgoing>to
<outgoing> db://maildb/spool/outgoing </outgoing>

Likewise, find the spool configuration and change it from file storage to database storage.
Modify dnsserver. Since the mail server is certain to send mail out to the internet, DNS is needed to resolve the recipient’s domain when delivering to the receiving server on the other side.

Also modify james‘s configuration.
Also change these 2 parameters to false
- Modify the validation

- Modify the network segment address used when accepting mail (you can set different values depending on your needs)

- Change the storage used when adding and deleting mail accounts to a database. Comment out the one above

- Create a new jdbc data source

Copy mysql-connection.jar into ../james-2.3.2/lib so that it gets loaded.
Restart the james service and you’re basically done.
Add an account for the mail server. The default login id is root and the password is also root
You can type help to get help.

Attached is the james download (my cloud drive): http://pan.baidu.com/s/1h57fQ

