1、安装postfix
yum remove sendmail
yum install postfix
1.1、修改postfix配置
vim /etc/postfix/main.cf,在文件最后加上如下配置
myhostname = m.wepu.org #本机名
mydomain = m.wepu.org #本机域名
inet_interfaces = all #监听来自所有网络端口
#配置postfix转发认证,添加如下配置
(以下内容来自/usr/share/doc/postfix-2.6.6/README-Postfix-SASL-RedHat.txt文件,)
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
reject_unauth_destination
1.2 启动postfix
service postfix start
2.安装sasl验证
yum search cyrus-sasl
确保安装以下的包
cyrus-sasl-lib-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-plain-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-lib-2.1.23-13.el6_3.1.i686
cyrus-sasl-2.1.23-13.el6_3.1.x86_64
yum install cyrus-sasl.x86_64
重启saslauthd服务
service saslauthd restart
确保添加开机启动 chkconfig saslauthd on
如果不启动该服务,认证会出现问题,直接导致gerrit邮件发送不成功
3、安装dovecot
yum install -y dovecot
vim /etc/dovecot/conf.d/10-ssl.conf
#ssl_cert = </etc/pki/dovecot/certs/dovecot.pem #屏蔽
#ssl_key = </etc/pki/dovecot/private/dovecot.pem #屏蔽
#并在文件最后加上
ssl = no
disable_plaintext_auth = no
auth_mechanisms = plain login
mail_location = mbox:~/mail:INBOX=/var/mail/%u #设置收件位置
vim /etc/dovecot/dovecot.conf 在文件最后加上如下配置
protocols = imap pop3 #启动imap pop3服务
4、安装roundcubemail(webmail)
下载roundcubemail 从官方wangzhan下载文件 (http://roundcube.net/download/)
tar zxvf roundcubemail-1.0.4.tar.gz
mv roundcubemail-1.0.4 /var/www/html/mail
chwon apache:apache -R /var/www/html/mail
cd /var/www/html/mail/config
cp config.inc.php.sample config.inc.php
编辑配置文件
vim config.inc.php
$config['db_dsnw'] = 'mysql://root:ws20130620@localhost/roundcubemail';
$config['default_host'] = 'm.wepu.org';
创建数据库
mysql
> CREATE DATABASE roundcubemail ;
> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost IDENTIFIED BY 'password';
执行脚本
mysql roundcubemail < SQL/mysql.initial.sql
重启httpd服务器
service httpd restart
5. 新建邮件用户
useradd admin
passwd admin
mkdir -p /home/admin/mail/.imap/INBOX # 创建用户的本地邮箱
chown admin:admin -R /home/admin/
true > /var/spool/mail/admin #清空以下邮箱,否则可能出现ERR Mailbox isn't a valid mbox file错误
6. 登录WebMail:http://IP/mail/
附加:
通过脚本添加用户
新建addmail.sh脚本 以下为脚本(运行 ./addmail.sh wepu 则添加邮箱地址wepu@m.wepu.org 密码wp20150113)
#!/bin/sh
#read -p mail: mail
#echo $mail
useradd $1
mkdir -p /home/$1/mail/.imap/INBOX
chown $1
1 -R /home/$1/
sed -i '$d' /etc/shadow
echo "$1:\$6\$B8sYsXSy\$NDQd0F/xXQ3JFSgO4e3pTR2sozxfoN2.zPrk/qxVjfCjc8yjqD8vM96IlK7UgOGSY5/o.hIpCtmgHC8KKfadT0:16456:0:99999:7:::" >> /etc/shadow
yum remove sendmail
yum install postfix
1.1、修改postfix配置
vim /etc/postfix/main.cf,在文件最后加上如下配置
myhostname = m.wepu.org #本机名
mydomain = m.wepu.org #本机域名
inet_interfaces = all #监听来自所有网络端口
#配置postfix转发认证,添加如下配置
(以下内容来自/usr/share/doc/postfix-2.6.6/README-Postfix-SASL-RedHat.txt文件,)
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
reject_unauth_destination
1.2 启动postfix
service postfix start
2.安装sasl验证
yum search cyrus-sasl
确保安装以下的包
cyrus-sasl-lib-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-plain-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-lib-2.1.23-13.el6_3.1.i686
cyrus-sasl-2.1.23-13.el6_3.1.x86_64
yum install cyrus-sasl.x86_64
重启saslauthd服务
service saslauthd restart
确保添加开机启动 chkconfig saslauthd on
如果不启动该服务,认证会出现问题,直接导致gerrit邮件发送不成功
3、安装dovecot
yum install -y dovecot
vim /etc/dovecot/conf.d/10-ssl.conf
#ssl_cert = </etc/pki/dovecot/certs/dovecot.pem #屏蔽
#ssl_key = </etc/pki/dovecot/private/dovecot.pem #屏蔽
#并在文件最后加上
ssl = no
disable_plaintext_auth = no
auth_mechanisms = plain login
mail_location = mbox:~/mail:INBOX=/var/mail/%u #设置收件位置
vim /etc/dovecot/dovecot.conf 在文件最后加上如下配置
protocols = imap pop3 #启动imap pop3服务
4、安装roundcubemail(webmail)
下载roundcubemail 从官方wangzhan下载文件 (http://roundcube.net/download/)
tar zxvf roundcubemail-1.0.4.tar.gz
mv roundcubemail-1.0.4 /var/www/html/mail
chwon apache:apache -R /var/www/html/mail
cd /var/www/html/mail/config
cp config.inc.php.sample config.inc.php
编辑配置文件
vim config.inc.php
$config['db_dsnw'] = 'mysql://root:ws20130620@localhost/roundcubemail';
$config['default_host'] = 'm.wepu.org';
创建数据库
mysql
> CREATE DATABASE roundcubemail ;
> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost IDENTIFIED BY 'password';
执行脚本
mysql roundcubemail < SQL/mysql.initial.sql
重启httpd服务器
service httpd restart
5. 新建邮件用户
useradd admin
passwd admin
mkdir -p /home/admin/mail/.imap/INBOX # 创建用户的本地邮箱
chown admin:admin -R /home/admin/
true > /var/spool/mail/admin #清空以下邮箱,否则可能出现ERR Mailbox isn't a valid mbox file错误
6. 登录WebMail:http://IP/mail/
附加:
通过脚本添加用户
新建addmail.sh脚本 以下为脚本(运行 ./addmail.sh wepu 则添加邮箱地址wepu@m.wepu.org 密码wp20150113)
#!/bin/sh
#read -p mail: mail
#echo $mail
useradd $1
mkdir -p /home/$1/mail/.imap/INBOX
chown $1

sed -i '$d' /etc/shadow
echo "$1:\$6\$B8sYsXSy\$NDQd0F/xXQ3JFSgO4e3pTR2sozxfoN2.zPrk/qxVjfCjc8yjqD8vM96IlK7UgOGSY5/o.hIpCtmgHC8KKfadT0:16456:0:99999:7:::" >> /etc/shadow