寻觅生命中的那一片浅草......

hMailServer+Roundcube+APMServ+希网二级域名+ADSL搭建邮件服务器

我们的目标是:将免费进行到底,Linux下的免费开源邮件解决方案很多了,如Emos,iRedOS等,
Windows下的就是hMailServer,可惜这个默认没有webmail,只能用客户端进行收发,网上看到有篇文章介绍hMailServer和Roundcube整合的,可惜不是很详细,所以决定自己整合下,另外,hMailServer默认就支持Squirrelmail,带了Squirrelmail Plugins的插件,但
Squirrelmail默认不支持中文,还需要下载语言包,Roundcube就内置了简体中文语言包。

Windows下免费的开源邮件解决方案
主要参考文章:
HOWTO: Install Roundcube with IIS6 and hMs internal DB:
http://www.hmailserver.com/forum/viewtopic.php?t=5591

开源的邮件服务器hMailServer:
http://www.alog.cn/article.asp?id=59

IRedMail-doc-MySQL-0.2-Roundcubemail-0.1.1
http://www.iredmail.org/wiki/index.php/IRedMail-doc-MySQL-0.2-Roundcubemail-0.1.1


系统环境:
Windows 2003 Standard Edition

所用软件:
Apache+Mysql+PHP环境:
APMServ5.2.6(选择Mysql版本为5.1)

Mail Server:
hMailServer-4.4.2-B277

webmail程序:
roundcubemail-0.1.1

一、将APMServ5.2.6解压缩到D盘下,修改php.ini文件,注意,每次修改php.ini后,要重启apache,

打开APMServ5.2.6,选择PHP设置—》修改配置文件

将101行的
output_buffering = off
修改为
output_buffering = on
当默认为off时,会报以下错误:
Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at D:\APMServ5.2.6\www\htdocs\webmail\installer\index.php:8) in D:\APMServ5.2.6\www\htdocs\webmail\installer\index.php on line 29

虽然对安装没影响,但总感觉不爽的

将第441行的
magic_quotes_gpc = on
修改为
magic_quotes_gpc = off

将第995行的
;session.save_path = “/tmp”
修改为,请根据实际路径修改
session.save_path = “D:/APMServ5.2.6/tmp/sessiondata”

二、安装hMailServer-4.4.2-B277

一直默认,去到“Select database server type”时,选择下面的“Use external database server”,然后一直next,去到数据库配置界面,打开APMServ,并点击“启动APMServ”(注意不要在安装hMailserver之前就启动APMServ,否则数据库配置的界面一直出不来,不知道为什么),选择“新建hMailserver数据库”,下一步,选择“MySQL Server”,下一步,填入数据库相关信息,本例中,数据距服务器地址:localhost, TCP端口:3306,数据库名:hmailserver,用户名:root,密码留空(APMServ5.2.6的Mysqlroot用户密码默认就是空),点击下一步,hMailserver安装程序会建立一个hmailserver的数据库,并将初始数据导入进去。接下来设置hMailServer管理员帐号administrator的密码。安装完毕,可以开启。

三、建立数据库,初始化数据库,修改roundcube相关文件

点击开始—》运行,输入cmd,去到D:\APMServ5.2.6\MySQL5.1\bin目录下,

###########新建roundcube会用到的数据库##########
D:\APMServ5.2.6\MySQL5.1\bin>mysqladmin.exe -uroot create roundcube

将roundcubemail-0.1.1解压缩到D:\APMServ5.2.6\www\htdocs下,命名为webmail,初始化roundcube
##########初始化数据库############
D:\APMServ5.2.6\MySQL5.1\bin>mysql.exe -uroot roundcube < D:\APMServ5.2.6\www\htdocs\webmail\SQL\mysql5.initial.sql

新建一个操作roundcube数据库的用户:
D:\APMServ5.2.6\MySQL5.1\bin>mysql.exe -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.1.28-rc-community MySQL Community Server (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

#############新建数据库用户##############
mysql> use mysql;
Database changed
mysql> insert into user(host,user,password) values (“localhost”,”roundcube”,password(“123456”));
Query OK, 1 row affected, 3 warnings (0.00 sec)

########刷新权限,使改变生效###########
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

########赋予用户roundcube对数据库roundcube的全权权限###########
mysql> grant all on roundcube.* to roundcube@”localhost”;
Query OK, 0 rows affected (0.00 sec)

########刷新权限,使改变生效###########
mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)

去到D:\APMServ5.2.6\www\htdocs\webmail\config下,将db.inc.php.dist,main.inc.php.dist改名为db.inc.php,main.inc.php,用文本编辑器打开db.inc.php,
根据以上的操作将
$rcmail_config[‘db_dsnw’] = ‘mysql://roundcube:pass@localhost/roundcubemail’;
修改为
$rcmail_config[‘db_dsnw’] = ‘mysql://roundcube:123456@localhost/roundcube’;

用文本编辑器打开main.inc.php
########开启安装#######

$rcmail_config[‘enable_installer’] = false;
修改为
$rcmail_config[‘enable_installer’] = true;

#########修改系统默认语言为中文#########

$rcmail_config[‘locale_string’] = ‘en’;
修改为
$rcmail_config[‘locale_string’] = ‘zh_CN’;

##########修改时区###############

$rcmail_config[‘timezone’] = intval(date(‘O’))/100 – date(‘I’);
修改为
$rcmail_config[‘timezone’] = 8;

四、申请带MX记录功能的二级域名:

登录:www.3322.org,注册一个用户,申请一个二级域名,如aaa.8800.org,下载客户端,然后安装,打开客户端
选择管理帐号,域名填aaa.8800.org,用户名,密码等填你注册时填写的,MX记录填写aaa.8800.org,然后点击增加,最后确定,等到“状态”列显示为可用,ping aaa.8800.org,看ping出来的地址是否就是你的公网IP

五、路由的NAT设置

登录路由器,做以下几个端口的NAT,假设架设邮件服务器的内网IP是192.168.1.121

IMAP 143 192.168.1.121
POP  110 192.168.1.121
SMTP 25  192.168.1.121
HTTP 80  192.168.1.121

六、新建Domain,建立该Domain帐号:
打开hMailServer,输入密码连接,右键Domains,选择add,Domain name 填入aaa.8800.org,点击Save,然后选择增加帐号,如Account address为test,Password为123456,点击Save,

选择Settings–》Protocols–》SMTP–》Delivery of e-mail,在Host name填入aaa.8800.org,点击Save。

七、安装Roundcube

打开浏览器,输入http://aaa.8800.org/webmail/installer
点击START INSTALLSTION,去到下一个页面,显示FileInfo:  NOT AVAILABLE和PostgreSQL:  NOT AVAILABLE(我们用的是Mysql,所以这个NOT AVAILABLE是没有关系的),不必理会,点击NEXT,最后一个测试配置的页面:

Test SMTP settings
Sender填写test@aaa.8800.org,Recipient填写收信人,经实践,发到QQ邮箱的马上就收到,我们填写一个QQ邮箱,如test@qq.com,点击 Send test mail,可能显示不成功,但过一会就OK了,可能是hMailserver处理没那么快吧!

Test SMTP settings
Server: PHP mail()
Port: 25

#############表示OK了#########
Trying to send email…
SMTP send:  OK

Sender  test@aaa.8800.org
Recipient  test@qq.com

Test IMAP configuration
Server  aaa.8800.org
Port 143
Username  test@aaa.8800.org
Password  123456

点击Check login,结果应该是:

Connecting to aaa.8800.org…
IMAP connect:  OK(SORT capability: yes)

好了,现在全都安装好了,删除installer文件夹,可以用浏览器打开http://aaa.8800.org/webmail/进行登录测试发邮件了。

已知问题:
直接发信到163收不到,但用163发信过来,可以收到,再回复过去,163那边就可以收到。

尚无评论

发表评论

2024年四月
« 5月    
1234567
891011121314
15161718192021
22232425262728
2930