Ubuntu+Sendmail+Dovecot+Openwebmail搭建邮件服务器
1. 安装apache
#apt-get install apache2
2. 安装sendmail
#apt-get install sendmail
sasl2-bin已经同时安装,如果自己安装需要将/etc/default/saslauthd start=no 改为yes才能启动服务。
2.1 设定Relay IP
在/etc/mail/access中添加允许Relay的地址
Connect:192.168.0.0 RELAY #允许192.168.0.0网络的IP地址通过sendmail发信,也可以写成192.168.0
2.2 设置收信的域名
在/etc/mail/local-host-names中添加收信的域名
ssh.tw
mail.ssh.tw
接收发往ssh.tw域和mail.ssh.tw域的邮件
2.3 设置sendmail侦听范围,默认只侦听本机
编辑/etc/mail/sendmail.mc,按照下边内容修改:
DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=0.0.0.0′)dnl
DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=0.0.0.0′)dnl
修改完成后使用一下命令使修改生效:
#m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
2.5 重启sendmail服务
#/etc/init.d/sendmail restart
3. 安装pop3服务
3.1 需要的包:dovecot-common,dovecot-pop3d
#apt-get install dovecot-common dovecot-pop3d
3.2修改配置文件/etc/dovecot/dovecot.conf(不使用ssl配置方法)
protocols = pop3
disable_plaintext_auth = no
ssl=no
mail_location = mbox:/var/mail:INBOX=/var/mail/%u
3.3重启dovecot服务
#/etc/init.d/dovecot restart
3.4 测试能否正常使用
telnet pop3_server 110
auth
user user_name
pass user_password
提示OK说明可以正常使用。
4. 安装openwebmail
4.1 下载openwebmail包
(地址:https://www.360docs.net/doc/a14901286.html,/openwebmail/download/release/)
使用wget命令下载最新版的包到/tmp
4.2 解压包到/var/www下
#tar xvzf openwebmail.tar.gz -C /var/www
4.3 安装所需要的包
#apt-get install perl-suid //不安装无法执行pl脚本
#apt-get install libapache2-mod-perl2 //安装后apache2可以支持cgi程序
4.4 修改cgi-bin的默认路径
编辑/etc/apache2/sites-available/default,修改下边两行:
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
修改后重启apache:
#/etc/init.d/apace2 restart
4.5 配置openwebmail所需要的配置文件:
4.5.1 将/var/www/cgi-bin/openwebmail/etc/default/auth_unix.conf
复制到/var/www/cgi-bin/openwebmail/etc目录下,并修改以下两行:
passwdfile_encrypted /etc/shadow
passwdmkdb none
4.5.2 将/var/www/cgi-bin/openwebmail/etc/default/dbm.conf
复制到/var/www/cgi-bin/openwebmail/etc/目录下,并修改以下一行:
dbm_ext .pag
4.5.3 修改/var/www/cgi-bin/openwebmail/etc/openwebmail.conf
mailspooldir /var/mail
ow_cgidir /var/www/cgi-bin/openwebmail
ow_cgiurl /cgi-bin/openwebmail
ow_htmldir /var/www/data/openwebmail
ow_htmlurl /data/openwebmail
default_language zh_CN.GB2312
default_iconset Cool3D.Chinese.Simplified #写不正确的话不显示图片
4.6 运行以下命令配置openwebmail
/va
r/www/cgi-bin/openwebmail/openwebmail-tool.pl –init
4.7 设置软连接访问openwebmail
在/var/www下建立openwebmail文件夹并建立软连接
#mkdir openwebmail
#cd openwebmail
#ln -s /var/www/data/openwebmail/redirect.html index.html
5. 访问http://serverip/openwebmail就可以访问openwebmail了。
6. 发送邮件需要smtp认证的单独设置
6.1先来看一下/usr/lib/sasl2/Sendmail.conf文件里面的内容应该是pwcheck_method:saslauthd,将这个 文件复制成smtpd.conf,这个文件也要在/usr/lib/sasl2/目录下:
#cp Sendmail.conf smtpd.conf
6.2 编辑sendmail.mc,添加以下两行
TRUST_AUTH_MECH(`DIGEST-MD5 LOGIN PLAIN’)
define(`confAUTH_MECHANISMS’,`DIGEST-MD5 LOGIN PLAIN’)
6.3 使配置生效:
#m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
#/etc/init.d/sendmail restart
#/etc/init.d/saslauthd restart