linux 下postfix邮箱的安装

 1、首先关闭sendmail服务
 service sendmail stop
 2、chkconfig sendmail off(关闭开机自启动)
 3、修改DNS正解文件,使DNS能够解析邮箱服务
 添加下面两行
 mail.zhubf.com. IN A            172.17.17.2
 zhubf.com.      IN MX   10      mail.zhubf.com.
 重启DNS服务
 service named  restart
 chkconfig named on
 echo "" > /etc/resolv.conf 
 测试DNS设置是否正确
 host mail.zhubf.com
 mail.zhubf.com has address 172.17.17.2                                 
 
                                               
 4安装postfix 软件包(前提安装yum,配置yum源)
 yum install -y postfix
 修改postfix配置文件
 
 vim /etc/postfix/main.cf
 
主要内容如下

 

5、配置saslauthd,这个软件默认是安装的
 修改saslauthd 配置文件
  vi /etc/sysconfig/saslauthd 
 设置MECH=shadow   
 service saslauthd restart
 chkconfig saslauthd on
 创建邮箱用户 
 useradd zhubf
 passwd  zhubf
  echo zhubf |passwd --stdin zhubf
 进行密码验证测试
 testsaslauthd -u zhubf -p 'zhubf'
 0: OK "Success."
 若没有通过,可能是防火墙或selinux的设置问题。
 
 在postfix的主配置文件/etc/postfix/main.cf添加如下权限设置
 smtpd_sasl_auth_enable = yes
 smtpd_sasl_local_domain = ''
 smtpd_recipient_restrictions = 
 
 permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
 broken_sasl_auth_clients = yes
 smtpd_client_restrictions = permit_sasl_authenticated
 smtpd_sasl_security_options = noanonymous
 
 重启postfix 服务
 service postfix restart
 chkconfig postfix on
 
 6、smtp认证的配置
  perl -MMIME::Base64 -e 'print encode_base64
 
 (zhubf)'
 emh1YmY=  
 
 telnet mail.zhubf.com  25
 ehlo zhubf.com
 进行加密验证
 auth login
 334 VXNlcm5hbWU6
 emh1YmY=
 334 UGFzc3dvcmQ6
 emh1YmY=
 235 2.0.0 Authentication successful      
 8、安装  dovecot服务
  yum install  -y dovecot   
 修改postfix主配置文件 
 vim /etc/postfix/main.cf
 
 修改dovecot的配置文件
 去掉注释
 vim /etc/dovecot.conf
 protocol pop3 {
      listen = *:10100
 #     ..
 }
 
 修改protocols =  pop3 pop3s
 
 重启dovecot服务
 /etc/init.d/dovecot restart
 chkconfig dovecot on
 
 9、安装cyrus-impad 服务
  yum install -y cyrus-imapd cyrus-imapd-devel
 
 修改postfix主配置文件
 vim /etc/postfix/main.cf
 去掉下面一行的注释
 mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
 重启服务
  /etc/init.d/cyrus-imapd restart
 passwd cyrus
                       
 添加邮箱用户
     # cyradm -u cyrus localhost     
 cm user.zhubf
 cm user.zhubf.Send
 cm user.zhubf.Trash
 cm user.zhubf.Drafts
 
 10、安装  squirrelmail软件
  yum install -y squirrelmail
 
 进行squirrelmail配置
 执行该文件
  /usr/share/squirrelmail/config/conf.pl 
 修改语言、邮箱基本设置等。
 
 11、邮箱测试
 http://mail.zhubf.com/webmail/
 使用刚刚创建的zhubf账号进行登录,发送一封邮件给自己,看看能否接收到,如果能接收到,则配置完成。