postfix

1.配置好两台主机的DNS    nm-connecction-editor

2.基本配置

postfix是通过SMTP简单邮件传输协议接收和转发邮件的软件

端口  25

服务日志文件  /var/log/maillog


3.修改配置   vim  /etc/postfix/main.cf(76 myhostname  =  www.mail.westos.com   设置主机名

                                                                  83  mydomain  =westos.com   设置域名

                                                                  99  myorigin  =  westos.com   设置发信源主机名

                                                                  116 inet_interfaces = all   25端口开启对外接口,默认只在127.0.0.1上开启

                                                                  164  mydestination = $myhostname,$mydomain,localhost    接收邮件结尾字符的指定)   

另一台主机也做相同修改,将westos换位qq即可

postfix



测试

westos主机向qq主机发送邮件    mail  [email protected]

(mail  查看邮件来源

 mailq查看邮件队列

 postqueue  -f 重新处理邮件队列)

postfix


qq主机向westos主机发送邮件   mail  [email protected]

(发送内容以.结尾

  mail 在本机查看是按q退出)


postfix

4.邮件别名和群发

(1)

修改配置文件     vim  /etc/aliases  (admin:             root   别名:真名

                                                              moreuser:    :include:/etc/postfix/moreuser   别名:记录群发到的用户文件)                  

                             vim  /etc/postfix/moreuser(root

     postfix                                                                        student)

创建文件        postalias   /etc/aliases

重启服务         systemctl  restart  postfix

postfix

结果:给amin用户发邮件,root用户收到

(2)群发   mail   [email protected]

(3)指定用户   mail  -u  student

结果:root用户和student用户都收到邮件

postfix

postfix

5.限制客户端发送    postconf   -e   "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"

打开主配置文件     vim  /etc/pstfix/main.cn

postfixpostfix


添加配置文件   vim  /etc/postfix/access(172.25.254.97    REJECT   客户端IP   拒绝访问)

文件加密   postmap   /etc/postfix/access

重启服务    systemctl    restart  postfix

postfix



6.限制用户发送     postconf   -e   "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"

打开主配置文件     vim  /etc/pstfix/main.cn

postfix

postfix


添加配置文件    vim   /etc/postfix/sender([email protected]   REJECT  用户邮箱   拒绝)

文件加密   postmap   /etc/postfix/sender

重启服务    systemctl    restart    postfix

postfix


7.限制用户接受     postconf   -e   "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip

打开主配置文件   vim  /etc/postfix/main.cn


postfix


添加配置文件   vim  /etc/postfix/recip([email protected]   REJECT  用户邮箱  拒绝)

文件加密   postmap  /etc/postfix/recip

重启服务   systemctl   restart   postfix

postfix


8.出站地址伪装    

postconf   -e   "smtpd_generic_maps =  hash:/etc/postfix/generic"

打开主配置文件   vim  /etc/postfix/main.cn

postfix

修改配置文件   vim  /etc/postfix/generic([email protected]   [email protected]  真实名字   虚拟名字)

文件加密   postmap  /etc/postfix/generic

重启服务   systemctl   restart   postfix

postfix


结果:[email protected]发出的邮件,[email protected]显示为时[email protected]发出的


9.入站地址转换    

配置DNS   dig  -t  mx  haha.com

postfix


postconf   -e   "virtual_alias_maps = hash:/etc/postfix/virtual"

vim  /etc/postfix/virtual([email protected]  [email protected]   虚拟名字   真实名字)

postfix

postfix

结果:发送给[email protected]的邮件,[email protected]收到


10.dovecot

(1)基本知识:dovecot是接受邮件服务器

支持协议    协议端口

pop3            110

pop3s          995

imap            143

imaps          993


配置好yum并安装服务    yum  install  dovecot  -y

postfix


修改配置文件   vim  /etc/dovecot/dovecot.conf(24  protocols = imap  pop3 lmtp  加密协议是imap、pop3、lmtp

                                                                                  48  login_trusted_networks = 0.0.0.0/0  允许任何IP连接

                                                                                  49   disable_plaintext_auth = no   允许明文登录)


postfix

修改配置文件   vim  /etc/dovecot/conf.d/10-mail.conf( 30 mail_location = mbox:~/mail:INBOX=/var/mail/%u   指定查看的用户文件)

重启服务   systemctl  restart  dovecot

postfix


测试步骤:在westos用户下  建立邮件目录    mkdir  mail/.imap  -p

                                                   建立查看的邮件文件位置   touch   mail/.imap/INBOX

                     在root用户下    自动建立邮件目录   mkdir   /etc/skel/mail/.imap  -p

                                                自动建立查看的邮件文件位置   touch  /etc/skel/mail/.imap/INBOX

postfix

mutt   -f  pop://[email protected]