准备:
环境winxp + jdk1.6 + tomcat6.0.16
apache james2.3 (邮件服务器)
Claros inTouch2.1.war (WebMail界面程序)
<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>
安装:
1、安装james邮件服务容器:james下载后直接解压后启动就可以了,
对james_home\apps\james\SAR-INF\config.xml做修改。
1.1:修改自己的邮件服务名,如同
[email protected]
<!---->
1
<
postmaster
>
[email protected]
</
postmaster
>
2
<
servernames
autodetect
="true"
autodetectIP
="true"
>
3
<
servername
>
byzh.com
</
servername
>
4
</
servernames
>
1.2:修改dns服务。
1
<
dnsserver
>
2
<
servers
>
3
<
server
>
byzh.com
</
server
>
4
<
server
>
smtp.163.com
</
server
>
5
<
server
>
mail.126.com
</
server
>
6
</
servers
>
7
<!--
修改自动探测为false 如果为true 可能在开发时出现异常
-->
8
<
autodiscover
>
false
</
autodiscover
>
9
<
authoritative
>
false
</
authoritative
>
10
<
maxcachesize
>
50000
</
maxcachesize
>
11
</
dnsserver
>
修改了dns,就要注释掉以下配置
1
<
mailet
match
="RemoteAddrNotInNetwork=127.0.0.1"
class
="ToProcessor"
>
2
<
processor
>
relay-denied
</
processor
>
3
<
notice
>
550 - Requested action not taken: relaying denied
</
notice
>
4
</
mailet
>
并且,开启SMTP Server 身份验证:
1
<
authRequired
>
true
</
authRequired
>
1.3:修改远程管理。以便在cmd控制台中执行telnet byzh.com 4566命令。
<!---->
1
<
remotemanager
enabled
="true"
>
2
<
port
>
4566
</
port
>
3
<
handler
>
4
<
helloName
autodetect
="true"
>
myMailServer
</
helloName
>
5
<
administrator_accounts
>
6
<
account
login
="root"
password
="123456"
/>
7
</
administrator_accounts
>
8
<
connectiontimeout
>
60000
</
connectiontimeout
>
9
<
prompt
>
welcome to mt Sever
>
</
prompt
>
10
</
handler
>
11
</
remotemanager
>
1.4:修改pop3,stmp,nntp服务。
<!---->
1
<
pop3server
enabled
="true"
>
2
<
port
>
110
</
port
>
3
<
handler
>
4
<
helloName
autodetect
="true"
>myMailServer
</
helloName
>
5
<
connectiontimeout
>
120000
</
connectiontimeout
>
6
</
handler
>
7
</
pop3server
>
8
<
smtpserver
enabled
="true"
>
9
<
port
>
25
</
port
>
10
<
handler
>
11
<
helloName
autodetect
="true"
>
myMailServer
</
helloName
>
12
<
connectiontimeout
>
360000
</
connectiontimeout
>
13
<
authRequired
>
true
</
authRequired
>
14
<
authorizedAddresses
>
127.0.0.0/8
</
authorizedAddresses
>
15
<
maxmessagesize
>
0
</
maxmessagesize
>
16
</
handler
>
17
</
smtpserver
>
18
<
nntpserver
enabled
="true"
>
19
<
port
>
119
</
port
>
20
<
handler
>
21
<
helloName
autodetect
="true"
>
myMailServer
</
helloName
>
22
<
connectiontimeout
>
120000
</
connectiontimeout
>
23
<
authRequired
>
false
</
authRequired
>
24
</
handler
>
25
</
nntpserver
>
1.5:
James邮件用户的用户信息默认保存在apps\james\var\users目录下,
通过修改配置文件apps\james\SAR-INF\config.xml,可以把用户信息保存到数据库中,
配置方法如下
打开config.xml,找到<users-store>这一项,此面默认的内容为:
<!---->
1
<
repository
name
="LocalUsers"
class
="org.apache.james.userrepository.UsersFileRepository"
>
2
<
destination
URL
="file://var/users/"
/>
3
</
repository
>
需要修改为:
<!---->
1
<
repository
name
="LocalUsers"
class
="org.apache.james.userrepository.JamesUsersJdbcRepository"
destinationURL
="db://maildb/users"
>
2
<
sqlFile
>
file://conf/sqlResources.xml
</
sqlFile
>
3
</
repository
>
通过修改,我们就把用户信息的存储介质从file改成了db,<sqlFile>是指明了在db中的数据表结构及相关数据库信息。
仍然是config.xml,找到<data-sources>项,注意先要创建好java_mail数据库,把此项内容修改为:
<!---->
1
<
data-source
name
="maildb"
class
="org.apache.james.util.mordred.JdbcDataSource"
>
2
<
driver
>
com.mysql.jdbc.Driver
</
driver
>
3
<
dburl
>jdbc:mysql://127.0.0.1:3306/java_mail?useUnicode=true&characterEncoding=UTF-8
</
dburl
>
4
<
user
>
root
</
user
>
5
<
password
>root</
password
>
6
<
max
>
20
</
max
>
7
</
data-source
>
<driver>是指MySQL的JDBC驱动,<dburl>指数据库的访问路径,IP后的mail即MySQL中新建数据库名,接下来是用户名、密码及最大连接数。
至此,数据库配置完成,启动James,若正常无误,请通过telnet添加一个新用户,比如adduser holen 123456,然后检查MySQL中的mail数据库,下面将有一个表users,这是James根据james_home\apps\james\conf的内容创建的。
通过以上配置,James的用户信息就可以保存在数据库中了。
1.6:修改c:/windows/system32/drivers/etc/hosts文件,增加一个地址映射。
<!---->
1
#192.168.0.100 byzh.com
2
127.0.0.1 byzh.com
1.8:执行james_home\bin\run.bat,启动james2.3服务。
1.8:进入命令模式,执行telnet byzh.com 4566,连接james2.3服务。
1.9:以管理员省份登录james2.3服务,用户就是1.3节配置的root/123456。
1.9.1:添加2个用户,a/123456,b/123456。
2:安装claros inTouch,下载claros-intouch-2.1,把intouch2.war拷贝到tomcat中。配置tomcat_home\webapps\intouch2\WEB-INF\config\config.xml。
<!---->
<?
xml version="1.0" encoding="UTF-8"
?>
<
claros-config
>
<
common-params
>
<
charset
>
utf-8
</
charset
>
<
server-timezone
>
Europe/Istanbul
</
server-timezone
>
<
tmp-dir
>
/tmp
</
tmp-dir
>
<
max-attachment-size
>
5
</
max-attachment-size
>
<
max-mail-size
>
10
</
max-mail-size
>
<
title
>
Claros inTouch 2.1
</
title
>
<
spam-check-enabled
>
false
</
spam-check-enabled
>
<
default-lang
>
zh_cn_utf8
</
default-lang
>
<
rss-feed
>
http://rss.cnn.com/rss/cnn_topstories.rss
</
rss-feed
>
</
common-params
>
<
chat
>
<
default-domain
>
claros.org
</
default-domain
>
<
msn-transport
>
msn.claros.org
</
msn-transport
>
<
yahoo-transport
>
yahoo.claros.org
</
yahoo-transport
>
<
icq-transport
>
icq.claros.org
</
icq-transport
>
<
aol-transport
>
aol.claros.org
</
aol-transport
>
</
chat
>
<
servers
>
<
server
>
<
shortname
>
byzh.com
</
shortname
>
<!--
your imap/pop3 server ip/dns
<fetch-server-port>143</fetch-server-port>
<fetch-protocol>imap</fetch-protocol>
-->
<
fetch-server
>
byzh.com
</
fetch-server
>
<
fetch-server-port
>
110
</
fetch-server-port
>
<
fetch-protocol
>
pop3
</
fetch-protocol
>
<
fetch-ssl
>
false
</
fetch-ssl
>
<
smtp-server
>
byzh.com
</
smtp-server
>
<
smtp-server-port
>
25
</
smtp-server-port
>
<
smtp-authenticated
>
true
</
smtp-authenticated
>
<
smtp-ssl
>
false
</
smtp-ssl
>
<!--
IMAP only: if you use courier or cyrus you'll need to set the following to "INBOX."
(with the dot(.) but omit the quotes)
-->
<
folder-namespace
></
folder-namespace
>
</
server
>
</
servers
>
<
db-config
>
<
db
>
<!--
do not change the term file -->
<
id
>
file
</
id
>
<
database
>
jdbc:mysql://127.0.0.1:3306/java_mail?useUnicode=true&characterEncoding=UTF-8
</
database
>
<
driver
>
com.mysql.jdbc.Driver
</
driver
>
<
login
>
root
</
login
>
<
password
>
root
</
password
>
</
db
>
</
db-config
>
</
claros-config
>
注意点:安装路径不能带空格,不然会找不到config.xml。
正常情况下就可以登录了,数据库使用了是MySQL。
2.1:同样在java_mail数据库中创建inTouch webmail需要的表,sql如下:
<!---->
1
CREATE
TABLE
`CALENDAR_OBJECTS` (
2
`ID`
bigint
(
20
) unsigned
NOT
NULL
auto_increment,
3
`USERNAME`
varchar
(
255
)
NOT
NULL
default
''
,
4
`RECORD_DATE`
timestamp
NOT
NULL
,
5
`REPEAT_TYPE`
int
(
11
)
NOT
NULL
default
'
0
'
,
6
`CATEGORY`
varchar
(
255
)
NOT
NULL
default
''
,
7
`DESCRIPTION`
text
NOT
NULL
,
8
`REMINDER_DAYS`
int
(
11
)
NOT
NULL
default
'
0
'
,
9
PRIMARY
KEY
(`ID`)
10
) ENGINE
=
InnoDB
default
charset
=
utf8;
11
12
#
Dump
of
table
CONTACTS
13
#
--
----------------------------------------------------------
14
15
CREATE
TABLE
`CONTACTS` (
16
`ID`
bigint
(
20
) unsigned
NOT
NULL
auto_increment,
17
`USERNAME`
varchar
(
255
)
default
''
,
18
`FIRST_NAME`
varchar
(
100
)
NOT
NULL
default
''
,
19
`MIDDLE_NAME`
varchar
(
100
)
default
''
,
20
`LAST_NAME`
varchar
(
100
)
NOT
NULL
default
''
,
21
`TITLE`
varchar
(
50
)
default
''
,
22
`SEX`
varchar
(
10
)
default
''
,
23
`GSM_NO_PRIMARY`
varchar
(
30
)
default
''
,
24
`GSM_NO_ALTERNATE`
varchar
(
30
)
default
''
,
25
`EMAIL_PRIMARY`
varchar
(
255
)
default
''
,
26
`EMAIL_ALTERNATE`
varchar
(
255
)
default
''
,
27
`WEB_PAGE`
varchar
(
255
)
default
''
,
28
`PERSONAL_NOTE`