平台centos6.5 x86_64最小化安装php
一,系统设置html
1,echo 'yourserverIP localhost' > /etc/hostslinux
2,sed -i 's/HOSTNAME=*/HOSTNAME=hostname.yourdomain.com/g' /etc/sysconfig/networknginx
3,添加你域名的A记录(hostname.yourdomain.com A 默认 12.12.12.12)和MX记录(@ MX 默认 hostname.yourdomain.com),命令host -t mx yourdomain.com确认MX记录生效web
4,修改时区 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtimecentos
clock -w #同步BIOS时间服务器
二,安装postfix网络
yum update -ydom
rpm -q postfix dovecot sendmail dovecot和sendmail默认没有安装socket
yum install -y dovecot
vi /etc/postfix/main.cf
myhostname = mail.yourdomain.com 指email服务器的域名
mydomain = yourdomain.com 指系统的主机名称
myorigin = $mydomain 指定本地发送邮件中来源和传递显示的域名
inet_interfaces = all 设置网络接口以便Postfix能接收到邮件
mynetworks = 127.0.0.0/8 指定受信任SMTP的列表
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
relay_domains = $mydestination 系统传递邮件的目的域名列表
home_mailbox = Maildir/ 设置邮箱路径与用户目录
添加如下设置启用sasl
smtpd_sasl_type = dovecot 启用dovecot-sasl认证
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes 启用sasl受权
smtpd_sasl_local_domain = $myhostname sasl的本地域
smtpd_sasl_security_options = noanonymous 不容许匿名登陆
broken_sasl_auth_clients = yes 客户端兼容支持
smtpd_recipient_restrictions =permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_client_restrictions = permit_sasl_authenticated
message_size_limit = 102400000
mailbox_size_limit = 204800000
chkconfig postfix on
service postfix restart
查看具体有效配置项参数
postconf -n
测试一
yum install -y mailx
mail -s 'hello' 12345667@qq.com < /etc/hosts
测试二
yum install -y telnet
telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mail.yourdomain.com ESMTP Postfix
输入ehlo yourserverIP
退出quit
三,配置dovecot
1,vi /etc/dovecot/dovecot.conf 支持pop3和imap协议
protocols = imap pop3 lmtp
listen = *
2,vi /etc/dovecot/conf.d/10-auth.conf 指明建立的Unix socket使用的权限,以及用户和组属性
disable_plaintext_auth = no 容许密码明文认证
auth_mechanisms = plain login
3,vi /etc/dovecot/conf.d/10-mail.conf 设置邮箱文件存放位置
mail_location = maildir:~/Maildir
4,vi /etc/dovecot/conf.d/10-master.conf 设置dovecot-sasl认证
# commented on these line:
#unix_listener auth-userdb {
#mode = 0600
#user =
#group =
#}
# change or setup on these line:
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
5,vi /etc/dovecot/conf.d/10-ssl.conf 关闭ssl加密(这里为了便于测试)
修改成ssl = no
6,vi /etc/dovecot/conf.d/20-pop3.conf
# uncomment on these line:
pop3_uidl_format = %08Xu%08Xv
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
chkconfig dovecot on
service dovecot start
查看具体有效配置项参数
dovecot -n
telnet localhost 110
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready. 服务已ok
quit 退出
+OK Logging out
Connection closed by foreign host.
四,建立帐户
Postfix默认用系统用户做为邮件帐号,须要添加Linux系统用户帐号相互收发邮件测试
groupadd mailusers
adduser -g mailusers -s /sbin/nologin test
passwd test
mkdir -p /home/test/Maildir
chown test:mailusers /home/test/Maildir
chmod -R 700 /home/test/Maildir
下载Foxmail测试该帐号收发邮件
http://www.linuxde.net/2013/07/14774.html
也能够安装webmail(就是squirrelmail 界面较老 基本能用)
wget https://nchc.dl.sourceforge.net/project/squirrelmail/stable/1.4.22/squirrelmail-webmail-1.4.22.tar.gz
tar zxvf squirrelmail-webmail-1.4.22.tar.gz
mv squirrelmail-webmail-1.4.22 webmail
cd webmail/
config/conf.pl (./configure)
选1. Organization Preferences -->6. Default Language : en_US 改为zh_CN
2. Server Settings -->1. Domain : mydomain.com 改为本身的域名 -->A. Update IMAP Settings : localhost:143 (cyrus)改为(courier)
4. General Options -->1.Data Directory : 改成/var/www/html/webmail/data/ -->2.Attachment Directory :改成/var/www/html/webmail/attach/
10.language preferences -->1.Default Language :改成zh_CN -->2.Default Charset :改成UTF-8
最好s保存q退出
下载中文语言包:
https://nchc.dl.sourceforge.net/project/squirrelmail/locales/1.4.18-20090526/all_locales-1.4.18-20090526.tar.gz
将其解压到WebMail
修改邮件存放目录权限
chown -R nginx:nginx /var/www/html/webmail/data/
在nginx配置文件中server{}段添加以下两段
location /webmail {
root /var/www/html/;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
}
location ~ /webmail/.*\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/$uri;
include fastcgi_params;
}
service nginx restart
而后http://SERVERIP/webmail就能用创建的系统帐号收发邮件了。