实战postfix邮件发送
实验环境:服务器端server: willis.com 172.25.254.1客户端desktop: desktop.com 172.25.254.2 实验内容: 1.邮件远程发送2.邮件别名3.邮件群发4.空壳邮件服务搭建5.不同服务器之间邮件传送(DNS邮件解析)6.出栈地址伪装 7.客户端主机名/地址限制 :(通过IP限制发件) 8.通过发件人地址进行限制 :(通过地址限制发件)9.通过收件人地址进行过滤 :(限制收件) 1.邮件远程发送1.1服务端 1.1-1 systemctl stop firewalldyum install postfix 1.1-2vim /etc/postfix/main.cf mydomain = willis.com #收件方看到的方邮件方主机名 myorigin = $mydomain inet_interfaces = all #开启接口 #inet_interfaces = localhost #关闭只允许本地访问 mydestination = $myhostname, $mydomain, localhost # 1.1-3.systemctl restart postfix netstat antlpe |grep master #查看端口 [root@willis ~]# netstat -antple |grep master tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 0 43632 2497/master tcp6 0 0 :::25 :::* LISTEN 0 43633 2497/master 1.2.远程发送端(客户端) [root@desktop ~]# yum install telnet -y [root@desktop ~]# telnet 172.25.254.1 25 Trying 172.25.254.1... Connected to 172.25.254.1. Escape character is '^]'. 220 linux.com ESMTP Postfixehlo hello250-linux.com 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN 2.邮件别名 2.1.vim /etc/aliases 最后添加 admin: root ###给root一个别名为admin 2.2.postalias /etc/aliases ###重读别名文件 2.3.systemctl restart postfix 2.4.id admin ###可查看到admin用户不存在 mail admin ###相当于给root用户发送邮件 mail ###查看root用户的邮件[root@willis ~]# vim /etc/aliases [root@willis ~]# postalias /etc/aliases [root@willis ~]# systemctl restart postfix.service [root@willis ~]# id willis id: willis: no such user [root@willis ~]# mail willis Subject: hello hello , my name is willis,how are you. . EOT [root@willis ~]# mail Heirloom Mail version 12.5 7/5/10. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 root Fri Sep 9 10:36 18/567 "hello" & 1 Message 1: From root@willis.com Fri Sep 9 10:36:54 2016 Return-Path: <root@willis.com> X-Original-To: willis Delivered-To: willis@willis.com Date: Fri, 09 Sep 2016 10:36:54 +0800 To: willis@willis.com Subject: hello User-Agent: Heirloom mailx 12.5 7/5/10 Content-Type: text/plain; charset=us-ascii From: root@willis.com (root) Status: R hello , my name is willis,how are you. & q Held 1 message in /var/spool/mail/root 3.邮件群发 1.vim /etc/postfix/moreuser root student 2.vim /etc/aliases 最后添加 more: :include:/etc/postfix/moreuser 3.postalias /etc/aliases 4.systemctl restart postfix 5.mail more ###群发邮件 mail ###查看root用户的邮件 mail -u student ###查看student用户的邮件 [root@willis ~]# >/var/spool/mail/root [root@willis ~]# useradd student [root@willis ~]# vim /etc/postfix/moreuserrootstudent [root@willis ~]# vim /etc/aliases [root@willis ~]# postalias /etc/aliases [root@willis ~]# systemctl restart postfix.service [root@willis ~]# mail more Subject: hello-world hello world. . EOT [root@willis ~]# mail Heirloom Mail version 12.5 7/5/10. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 root Fri Sep 9 10:42 21/661 "hello-world" & q Held 1 message in /var/spool/mail/root [root@willis ~]# mail -u student Heirloom Mail version 12.5 7/5/10. Type ? for help. "/var/mail/student": 1 message 1 new >N 1 root Fri Sep 9 10:42 21/664 "hello-world" & q Held 1 message in /var/mail/student 4.空壳邮件服务搭建 4.1.在desktop(另外一台仅中转邮件的服务器,空壳端)上 postconf -e "inet_interfaces = all" postconf -e "mydomain = willis.com" postconf -e 'myorigin = $mydomain' postconf -e "mydestination = " postconf -e "relayhost = 172.25.254.1" postconf -e "local_transport = error:local delivery disabled " systemctl restart postfix.service (附注:火墙要关闭systemctl stop firewalld selinux要置0 setenforce 0 )[root@desktop ~]# postconf -e "mydomain = willis.com" [root@desktop ~]# postconf -e 'myorigin = $mydomain' [root@desktop ~]# postconf -e "mydestination = " [root@desktop ~]# postconf -e "relayhost = 172.25.254.1" [root@desktop ~]# postconf -e "local_transport = error:local delivery disabled " [root@desktop ~]# systemctl restart postfix.service 4.2.在主服务器server上 postconf -e "mynetworks = 127.0.0.0/8 172.25.254.0/24" #接受来自那个网段的邮件 systemctl restart postfix.service (附注:火墙要关闭systemctl stop firewalld selinux要置0 setenforce 0 )[root@willis ~]# postconf -e "mynetworks = 127.0.0.0/8 172.25.254.0/24" You have mail in /var/spool/mail/root [root@willis ~]# systemctl restart postfix.service 4.3.实验验证 在desktop(另外一台仅中转邮件的服务器)上(> /var/log/maillog ###清空邮件日志) mail root ###发送文件[root@desktop ~]# >/var/log/maillog [root@desktop ~]# mail root Subject: beautiful world Threr are many beautiful things. . EOT [root@desktop ~]# mail No mail for root在主服务器server上( > /var/spool/mail/root ###清空邮件) mail ###查看文件 [root@willis ~]# >/var/spool/mail/root [root@willis ~]# mail Heirloom Mail version 12.5 7/5/10. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 root Fri Sep 9 10:54 21/756 "beautiful world" & q Held 1 message in /var/spool/mail/root 5.不同服务器之间的邮件传送(DNS邮件解析记录) 将前面做实验的环境恢复到初始状态。vim /etc/postfix/main.cf mydomain = willis.com myorigin = $mydomain inet_interfaces = all #inet_interfaces = localhost mydestination = $myhostname, $mydomain, localhost 5-1server端配置dns hostnamectl set-hostname mail.willis.com 安装DNS:yum install bind -y1)vim /etc/resolv.conf search willis.comnameserver 172.25.254.12)vim /etc/named.rfc1912.zoneszone "willis.com" IN {type master;file "willis.com.zone";allow-update { none; }; }; zone "redhat.com" IN {type master;file "redhat.com.zone";allow-update { none; }; };3)cd /var/named/ cp -p named.localhost willis.com.zone4)vim willis.com.zone$TTL 1D @ IN SOA dns.willis.com. root. (0 ; serial1D ; refresh1H ; retry1W ; expire3H ) ; minimumNS dns.willis.com. dns A 172.25.254.1 willis.com. MX 1 172.25.254.1.5)cp -p willis.com.zone redhat.com.zone vim redhat.com.zone$TTL 1D @ IN SOA dns.redhat.com. root. (0 ; serial1D ; refresh1H ; retry1W ; expire3H ) ; minimumNS dns.redhat.com. dns A 172.25.254.1 redhat MX 1 172.25.254.2. 6)systemctl start named 5-2 . desktop端配置hostnamectl set-hostname mail.redhat.com 1)vim /etc/resolv.conf search redhat.com nameserver 172.25.254.1 2)测试 mail root@willis.com mail root@redhat.com [root@mail ~]# mail root@willis.com Subject: hello-willis hello . you are a good boy. . EOT [root@mail ~]# mail root@redhat.com Subject: hello goog boy Are you ok now? . EOT You have new mail in /var/spool/mail/root [root@mail ~]# mail [root@mail ~]# mail root@redhat.com Subject: hello good boy. Are you OK now? . EOT [root@mail ~]# mail Heirloom Mail version 12.5 7/5/10. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 root Fri Sep 9 12:24 18/569 "hello good boy." & 1 Message 1: From root@redhat.com Fri Sep 9 12:24:07 2016 Return-Path: <root@redhat.com> X-Original-To: root@redhat.com Delivered-To: root@redhat.com Date: Fri, 09 Sep 2016 12:24:07 +0800 To: root@redhat.com Subject: hello good boy. User-Agent: Heirloom mailx 12.5 7/5/10 Content-Type: text/plain; charset=us-ascii From: root@redhat.com (root) Status: R Are you OK now? 6.出栈地址伪装6.1服务器端(伪装端)vim /etc/postfix/generic增加root@willis.com admin@hello.compostmap generic ###生成generic.db文件postconf -d | grep genericpostconf -e "smtp_generic_maps = hash:/etc/postfix/generic"systemctl restart postfix.service测试 mail root@redhat.com[root@willis postfix]# mail root@redhat.com Subject: hello. 你好呀 . EOT 6.2 接受端[root@mail ~]# mail Heirloom Mail version 12.5 7/5/10. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 root Fri Sep 9 12:47 21/733 "hello." & 1 Message 1: From admin@hello.com Fri Sep 9 12:47:10 2016 Return-Path: <admin@hello.com> X-Original-To: root@redhat.com Delivered-To: root@redhat.com Date: Fri, 09 Sep 2016 12:47:11 +0800 To: root@redhat.com Subject: hello. User-Agent: Heirloom mailx 12.5 7/5/10 Content-Type: text/plain; charset=utf-8 From: admin@hello.com (root) Status: R 你好呀 7.客户端主机名/地址限制 :(通过IP限制发件) postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access" vim /etc/postfox/main.cf smtpd_client_restrictions = check_client_access hash:/etc/postfix/access, vim /etc/postfox/access 192.168.0.4 REJECT 192.168.0 REJECT postmap access systemctl restart postfix 8.通过发件人地址进行限制 :(通过地址限制发件) postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender" vim /etc/postfox/main.cf smtpd_sender_restrictions =check_sender_access hash:/etc/postfix/sender vim /etc/postfix/sender user@exmaple.com REJECT(OK、RELAY) postmap sender systemctl restart postfix9.通过收件人地址进行过滤 :(限制收件)postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient" vim /etc/postfox/main.cf smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient vim /etc/postfix/recipient user@example.com REJECT(OK、RELAY,DISCARDED) postmap recipient
本文转自willis_sun 51CTO博客,原文链接:http://blog.51cto.com/willis/1851049,如需转载请自行联系原作者
实战postfix邮件发送相关推荐
- Linux中Postfix邮件发送配置(三)
部署DNS服务器 postfix根据域名和地址做一个MX记录,A记录,PTR记录(一般在互联网上邮件服务器都要反解,没有PTR记录会认为是垃圾邮件) $ service iptables stop $ ...
- 烂泥:Postfix邮件服务器搭建之软件安装与配置
本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb Postfix邮件服务器的搭建需要使用到几个软件,分别是cyrus-sasl.postf ...
- [RHEL] RHEL7.0 下 Postfix + Dovecot 实现邮件发送
RHEL7.0 下 Postfix + Dovecot 实现邮件发送 一.前言 大家都对邮件服务(mail service)很感兴趣嘛.我在自己 博客站 预言了自己会实战一次,访问量一天到十几(毕竟平 ...
- html项目_Python Selenium项目实战之添加发送HTML测试报告邮件!
说明 继第一个实战项目的基础上添加自动发送报告邮件接口,代码有部分调整 变动 1.增加文本文档SendToUserinfo.txt 用来保存邮件接收者的信息 2.修改测试报告文件名称格式并添加repr ...
- 在Centos7下捣鼓邮件发送软件sendmail与postfix
虽然只是在整GITLAB过程中的一个小插曲,却意外的难搞, 花了我很多时间,网络上的各种教程与排错众说纷纭,看似简单的功能变得异常复杂. 邮件发送功能, 即MTA做为许多系统的必备,最常用的有send ...
- PHP复习_PDO实战之实现注册邮件发送
项目准备 首先,我们要实现PHP的邮件发送,我们要准备一下邮件发送的插件,php的邮件插件现在市面上一共有三种常用,PhpMailer.SwiftMailer.ZendMail 我们本次使用Swift ...
- Py自动化办公—Word文档替换、Excel表格读取、Pdf文件生成和Email自动邮件发送实战案例...
点击上方"Python爬虫与数据挖掘",进行关注 回复"书籍"即可获赠Python从入门到进阶共10本电子书 今 日 鸡 汤 平阳歌舞新承宠,帘外春寒赐锦袍. ...
- (Java每日一谈:第五日——破除抑郁症的小窗户)实战小技巧:邮件发送
今天小编会给大家讲解几个比较实用的编程常用技巧,邮件发送就是其中的一个,邮件发送的使用场景在日常的生活中也是非常常用,对于这一块的知识点不是很难以理解,大家可以学习完了之后,得到需要的时候,再找一找相 ...
- ssh项目实战----Spring计时器任务 Spring整合JavaMail(邮件发送)
一.常用数据频度维护 对于系统使用度较高的数据,客户在查看时希望这些数据最好先出现,此时需要为其添加排序规则.在进行排序时,使用次数成为排序的依据.因此需要设置一个字段用来描述某种数据的使用次数,也就 ...
最新文章
- Flutter开发之HTTP网络请求:HttpClient(26)
- Pandas——loc、iloc、ix 函数区别
- 腾讯云的ubuntu虚拟主机上再安装VirtualBox遇到的一些错误
- 使用机器学习预测天气_如何使用机器学习预测着陆
- Java面向对象——基础2 封装、继承、多态
- 亚马逊创始人下月将乘自家火箭进入太空 亲弟弟同行
- 诺基亚9 PureView五摄机皇再曝光 低配高价毫无诚意?
- java抠图边框颜色处理_java 实现抠图(项目应用场景:抠图章)
- 树堆(Treap)图文详解与实现
- python reference理解
- 提高COOKIE的安全性--相关解决方案
- cmos功能测试软件,CMOS摄像头开发测试方法(我总结的)
- word转PDF,导航窗格输出目录
- u盘怎么安装计算机系统,教您如何用u盘装系统
- CVPR2019| 中科院VIPL实验室11篇CVPR解读:弱监督学习、视频分割、目标检测
- 三张图片怎么拼成一张?
- html做键盘,用html+js+css做一个模拟键盘
- Web(七)CSS页面布局-网页布局页面的制作
- OpenCV图像处理学习四,像素的读写操作和图像反差函数操作
- 万用表怎么测量电池容量_万用表怎么检测电池容量_电池电量
热门文章
- python计算学习_跟老齐学Python之用Python计算
- python中pos的用法_Python正则式的基本用法
- 如何判断车与路边线距离_6家快递公司共享分拣线配送车,效果如何?
- Modelsim仿真查看内部信号
- python selenium自动化断言_python+selenium自动化登录测试,设计不同场景进行登录,两种方式断言,截图保存...
- 算法设计与分析 Fibonacci数列问题的词典法(动态规划:词典)
- matlab GUI gca gco gcf
- jupyter notebook运行出错:ModuleNotFoundError: No module named ‘keras‘ 解决办法
- HDLBits 系列(22) Shift register
- 【 FPGA 】时序分析中的基本概念和术语