首页 > 代码库 > 三.mail发送

三.mail发送

#### mail 文件发送 ####
1.配置环境(DNS)
vim /etc/resolv.conf
nameserver 172.25.254.114

vim /etc/named.rfc1912.zones
zone "linux.com" IN {
        type master;
        file "linux.com.zone";
        allow-update { none; };
};

zone "westos.com" IN {
        type master;
        file "westos.com.zone";
        allow-update { none; };
};

cd /var/named/
cp -p named.localhost westos.com.zone (同一服务器)
vim westos.com.zone
#############################################################
$TTL 1D
@       IN SOA  dns.westos.com. root.westos.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
                NS      dns.westos.com.
dns             A       172.25.254.114
westos.com.     MX 1    172.25.254.214.
#############################################################

cp -p named.localhost linux.com.zone (同一服务器)
vim linux.com.zone
#########################################################
$TTL 1D
@       IN SOA  dns.linux.com. root.linux.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
                NS      dns.linux.com.
dns             A       172.25.254.114
linux.com.      MX 1    172.25.254.114.
#########################################################

在客户端:
vim /etc/postfix/main.cf
需修改的地方:
75 myhostname = mailwestos.westos.com    ##主机名
83 mydomain = westos.com  ##域名
99 myorigin = $mydomain
113 inet_interfaces = all  ##开启所有端口
119 inet_protocols = all
164 mydestination = $myhostname, $mydomain, localhost  ##允许接收哪些mail

例如:(注意关闭防火墙)systemctl stop firewalld.service
mail root@westos.com
mailq  ##邮箱预处理项
postsuper -d 4B9DE17E849 (在mailq中)
postqueue -f   ##刷新mailq

在客户端:
邮箱存储在 /var/mail/root
> /var/mail/root  清空所储邮箱
postconf -e "inet_interface=localhost"
postconf -d | grep inet
inet_interfaces = all
inet_protocols = all


在server端:
vim /etc/aliases
postalias /etc/aliases
systemctl restart postfix.service
mail

vim /etc/postfix/generic
root@westos.com 955310782@qq.com   ##最后一行添加
mail 955310782@qq.com
mailq
postmap generic    ##用虚假邮箱地址发送
postconf -d | grep generic
postconf -e "smtp_genetic_maps = hash:/etc/postfix/generic"
systemctl restart postfix.service
mail root@linux.com

在另一台主机
talnet 172.25.254.100 25  ##端口25
ehlo hello  ##“打招呼” 检测是否成功

本文出自 “12100661” 博客,谢绝转载!

三.mail发送