Liunx学习篇第三章之~配置电子邮件传输(postfix)

电子邮件发送

>服务器使用SMTP协议将电子邮件提交至TCP端口25,或由本地客户端通过/usr/bin/sendmail程序进行提交。如果该  MTA是最终目标位置,邮件将传递至MDA。否则,将使用MX记录在DNS中查找下一个MTA,并使用SMTP进行转发
>MDA:“邮件发送代理”。MDA将邮件发送至收件人的本地邮件存储位置(默认情况下是/var/spool/mail/user)。Postfix提供自己的MDA,以发送至基于文件的本地默认邮件存储位置/usr/libexec/postfix/local.
>转发:电子邮件服务器(MTA)将提交的邮件转发至另一个服务器,以进行发送
>排队:失败的发送或转发尝试排队等待,并由MTA定义重试。(默认情况下,Postfix每小时执行此操作一次)
>拒绝:在首次提交期间,电子邮件被电子邮件服务器拒绝
>退回:远程服务器接受电子邮件以进行发送以后,又将该电子邮件退回给始发电子邮件服务器和/或用户
>电子邮件以进行发送以后,又将该电子邮件退回给始发电子邮件服务器和/或用户

---------------------------------------------------------------------postfix---------------------------------------------------------------------------------


1.postfix提供smtp协议用来投递邮件
默认端口25
默认日志 /var/log/maillog
mail [email protected]
Subject:hello
hello
.               ##用“.”来结束录入内容并发送

mailq           ##查看邮件队列
postqueue -f    ##重新处理邮件队列
默认情况下邮件端口只在127.0.0.1上开启
2.配置
vim /etc/postfix/main.cf
 116 inet_interfaces = all      ###25端口开启的网络接口
 76 myhostname = westos-mail.westos.com   ###指定mta主机名称
 83 mydomin = westos.com    ##指定mta的域名
 99 myorigin = westos.com     ##指定邮件来源结尾(@后面的内容)
 164 mydestination = $myhostname,$mydomain,localhost ###接收邮件结尾字符的指定
systemctl restart postfix.service

systemctl stop firewalld

测试:

发送端

Liunx学习篇第三章之~配置电子邮件传输(postfix)

接收端

Liunx学习篇第三章之~配置电子邮件传输(postfix)

3.邮件别名
1)  [qq-mail.qq.com]vim /etc/aliases

别名:              真名                                                  ##邮件别名

Liunx学习篇第三章之~配置电子邮件传输(postfix)

测试:

发送端

Liunx学习篇第三章之~配置电子邮件传输(postfix)

接收端

Liunx学习篇第三章之~配置电子邮件传输(postfix)

2)  moreuser:    :include:/etc/postfix/moreuser      ##邮件群发

vim /etc/postfix/moreuser

Liunx学习篇第三章之~配置电子邮件传输(postfix)

postalias /etc/aliases
测试:

发送端

Liunx学习篇第三章之~配置电子邮件传输(postfix)

接收端

Liunx学习篇第三章之~配置电子邮件传输(postfix)

4.通过远程主机测试邮件服务

yum install telnet -y

telnet 172.25.254.143 25
ehlo hello
mail from:[email protected]

rcpt to:[email protected]

测试:

Liunx学习篇第三章之~配置电子邮件传输(postfix)

接收端

Liunx学习篇第三章之~配置电子邮件传输(postfix)


5.邮件客户端的访问控制
在MTA上
postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"
vim /etc/postfix/main.cf
vim /etc/postfix/access
Liunx学习篇第三章之~配置电子邮件传输(postfix)
postmap /etc/postfix/access
systemctl restart postfix.service

测试:
172.25.254.243测试

Liunx学习篇第三章之~配置电子邮件传输(postfix)


6.限制用户发送
postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/sender"
vim /etc/postfix/sender
 用户@westos.com   REJECT
Liunx学习篇第三章之~配置电子邮件传输(postfix)
postmap /etc/postfix/sender
systemctl restart postfix
测试:
Liunx学习篇第三章之~配置电子邮件传输(postfix)

7.限制用户接收--------------
postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip"
vim /etc/postfix/recip
Liunx学习篇第三章之~配置电子邮件传输(postfix)
postmap /etc/postfix/recip
systemctl restart postfix

测试:
Liunx学习篇第三章之~配置电子邮件传输(postfix)

8.出站地址伪装
dns mx     地址解析
vim /etc/named.rfc1912.zones
    zone "sb.com" IN {
    type master;
    file "sb.com.zone";
cd /var/named
cp -p qq.com.zone sb.com.zone
vim sb/com.zone
systemctl restart named
postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"
vim /etc/postfix/generic
Liunx学习篇第三章之~配置电子邮件传输(postfix)

postmap /etc/postfix/generic
systemctl restart postfix

测试:
su - westos
mail [email protected]
接收端

Liunx学习篇第三章之~配置电子邮件传输(postfix)
9.入站地址转换
postfix -e "virtual_alias_maps = hash:/etc/postfix/virtual"
/etc/postfix/virtual
虚拟名字             真实名字
[email protected]        [email protected]
Liunx学习篇第三章之~配置电子邮件传输(postfix)
postmap /etc/postfix/virtual
systemctl restart postfix
 测试
mail [email protected]


Liunx学习篇第三章之~配置电子邮件传输(postfix)