第七题 配置邮件服务器

postfix学习网站:https://blog.csdn.net/mycms5/article/details/78773308 

system1和systemc2分别执行

[root@system2 ~]# postconf -e inet_interfaces=loopback-only
[root@system2 ~]# postconf -e mydestindation=
[root@system2 ~]# postconf -e local_transport=error:err
[root@system2 ~]# postconf -e relayhost=[mail.group8.example.com]
[root@system2 ~]# postconf -e myorigin=server.group8.example.com
[root@system2 ~]# systemctl enable postfix
[root@system2 ~]# systemctl restart postfix
[root@system2 ~]# echo "hello" | mail -s testmail dave

参数解释:

relayhost 设定中心邮件服务器
  收到的邮件全部转交给配置的服务器
inet_interfaces只在本地环回接口接受邮件
  loopback-only表示只接受本地邮件,只在127.0.0.1监听25号端口deli
myorigin 设定发信人的域
  假设发信人为lily,那么会将信件的发信人改为lily@server.group8.example.com
  如果配置选项为188.com,那么发信人lily就会被改为lily@188.com
mydestindation 将接收到的任何邮件都当做外部邮件,这样邮件才会转发的到中心邮件服务器
  收到的所有信件,不管收信人是谁,都不会保存。
  可以理解为收到的所有的邮件都要转出去。
local_transport
  当配置local_transport=error: local delivery disabled时,表示禁止本地分发邮件到本地用户邮箱
mynetworks 信任的网络
  只接受配置选项中网络的邮件

验证:

[root@system1 postfix]# curl http://server.group8.example.com/pub/received_mail/8
From root@server.group8.example.com Wed Apr ::
Return-Path: <root@server.group8.example.com>
X-Original-To: dave@server.group8.example.com
Delivered-To: dave@server.group8.example.com
Received: from system1.group8.example.com (system1.group8.example.com [172.24.8.11])
by server.group8.example.com (Postfix) with ESMTP id B5F0E3089EFD
for <dave@server.group8.example.com>; Wed, Apr :: + (CST)
Received: by system1.group8.example.com (Postfix, from userid )
id 9B87C22E33F0; Wed, Apr :: + (CST)
Date: Wed, Apr :: +
To: dave@server.group8.example.com
Subject: testmail
User-Agent: Heirloom mailx 12.5 //
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <.9B87C22E33F0@system1.group8.example.com>
From: root@server.group8.example.com (root) hello

紧急情况补救措施:
打开配置文件,搜索配错了的某一项,然后将该项进行删除,重新配置即可
vim /etc/postfix/main.cf
至此,考试内容结束

实验:配置只发邮件服务器

首先在两台机器上分别执行实验脚本

[root@server0 ~]# lab smtp-auth setup
[root@desktop0 ~]# lab smpt-auth setup

Server0:

[root@server0 ~]# postconf -e "relayhost=[smtp0.example.com]:587"
[root@server0 ~]# postconf -e "inet_interfaces=loopback-only"
[root@server0 ~]# postconf -e "mynetworks=127.0.0.0/8 [::1]/128"
[root@server0 ~]# postconf -e "myorigin=desktop0.example.com"
[root@server0 ~]# postconf -e "mydestination="
[root@server0 ~]# postconf -e "local_transport=error: local delivery disabled"

从下开始与普通邮件不同

[root@server0 ~]# postconf -e "smtp_use_tls=yes"
将用户名和密码以tls的形式加密
[root@server0 ~]# postconf -e "smtp_tls_loglevel=1"
日志级别
[root@server0 ~]# postconf -e "smtp_tls_security_level=encrypt"
信息加密
[root@server0 ~]# postconf -e "smtp_sasl_auth_enable=yes"
启用smtp发送验证
[root@server0 ~]# postconf -e "smtp_sasl_security_options=noanonymous"
禁止匿名
[root@server0 ~]# postconf -e "smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd"
用户密码所在文件

Server0配置

解释:只要是将邮件转给smtp0.example.com的587端口的,我们就用student:student

[root@server0 ~]# vim /etc/postfix/sasl_passwd
smtp0.example.com: student:student

修改密码文件权限为0600

[root@server0 ~]# chmod  /etc/postfix/sasl_passwd

修改文件格式

[root@server0 ~]# postmap /etc/postfix/sasl_passwd

其实真正使用的文件为/etc/postfix/sasl_passwd.db这个文件来验证也就是修改格式后的文件

重载服务

[root@server0 ~]# systemctl reload postfix

发送邮件

[root@server0 ~]# mail -s "server0 sasl tls" student@desktop0.example.com
sasl tls test. 这一行写邮件内容
.   用.来结束邮件内容
EOT

收信

[root@server0 student]# su student
[student@server0 ~]$ mutt -f imaps://imap0.example.com

验证:

Server0:

[root@server0 student]# lab-smtp-auth grade
Checking for Postfix configuration... PASS
Checking for Postfix TLS and SASL configuration... PASS
Desktop0: [root@desktop0 ~]# lab smtp-auth grade
Checking E-mail is present in student inbox... PASS

至此,实验结束

如果有什么建议或者意见,请直接在评论区留言或者私信本人,看到了第一时间回复。

本人Linux菜鸟,欢迎各位Linux大神指导。

Linux postfix配置方法的更多相关文章

  1. Linux时间同步配置方法

    由于是在做mongoDB的实验中再一次的遇到了mongos路由节点同步时由于ntp时间的问题导致同步非常的慢.故写了个时间同步的语句===> while :; do rdate -s 192.1 ...

  2. Linux防火墙配置方法

    1)查看防火墙状态 查看防火墙状态: /etc/init.d/iptables status 暂时关闭防火墙: /etc/init.d/iptables stop 重启防火墙: /etc/init.d ...

  3. Linux下配置ip地址四种方法

    linux系统安装完,以后通过命令模式配置网卡IP.配置文件通常是/etc/sysconfig/network-scripts/ifcfg-interface-nameifconfig后显示的内容,l ...

  4. linux邮件服务器postfix配置实例

    linux邮件服务器postfix配置实例(超级详细!!!) 2013-03-13 13:30:21 标签:邮件服务器 linux 1. 系统安装:1)centos4.3 选上MAIL组件里的全部.2 ...

  5. Linux安装配置php环境的方法

    本文实例讲述了Linux安装配置php环境的方法.分享给大家供大家参考,具体如下: 1.获取安装文件: http://www.php.net/downloads.php php-5.3.8.tar.g ...

  6. Linux 单网卡多 IP 的配置方法

     Linux 单网卡多 IP 的配置方法 1 .永久配置的方法: 知道在 Linux 下网卡被称为 eth0,eth1,eth2..... ,所有网卡的配置文件都存储在 /etc/sysconfi ...

  7. 在Linux下访问Windows共享目录的配置方法

    在Linux下访问Windows共享目录的配置方法 1.在Windows上设置一个共享目录 如:将d:\RedHat_disk设置为共享目录 2.在Windows上创建一个用户,如tommy,密码11 ...

  8. Linux环境下Swap配置方法

    Linux环境下Swap配置方法 场景: 今天下午安装一个CentOS6.5操作系统,忘记配置swap分区.看看如何安装系统之后,增加和删除swap分区.方法如下:1.内存占用情况[root@josh ...

  9. Linux NFS服务器的安装与配置方法(图文详解)

    这篇文章主要介绍了Linux NFS服务器的安装与配置方法(图文详解),需要的朋友可以参考下(http://xb.xcjl0834.com) 一.NFS服务简介 NFS 是Network File S ...

随机推荐

  1. [LeetCode] 582. Kill Process 终止进程

    Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each ...

  2. python 包多熟悉一个干活就轻松点

    包管理 管理包和依赖的工具. pip – Python 包和依赖关系管理工具. pip-tools – 保证 Python 包依赖关系更新的一组工具. conda – 跨平台,Python 二进制包管 ...

  3. 【LeetCode】最接近的三数之和【排序,固定k1,二分寻找k2和k3】

    给定一个包括 n 个整数的数组 nums 和 一个目标值 target.找出 nums 中的三个整数,使得它们的和与 target 最接近.返回这三个数的和.假定每组输入只存在唯一答案. 例如,给定数 ...

  4. 一起来学Spring Cloud | 第八章:消息总线(Spring Cloud Bus)

    上一章节,我们讲解了分布式配置中心spring cloud config,我们把配置项存放在git或者本地,当我们修改配置时,需要重新启动服务才能生效.但是在生产上,一个服务部署了多台机器,重新启动比 ...

  5. lmir 随笔

    近期需要研究一些特征工程的工作,就打算把微软之前公布出来的特征都复现一遍,今天遇到的特征是 LMIR, 其实也就是language model for information retrieval的简写 ...

  6. tkinter学习笔记_01

    知识点目录: 1. 文本框 Label var = tk.StringVar() # 文本框 bg 背景颜色 fonnt 字体设置 width 长 height 高 l = tk.Label(root ...

  7. fastjson反序列化使用不当导致内存泄露

    分析一个线上内存告警的问题时,发现了造成内存告警的原因是使用fastjson不当导致的. 分析dump发现com.alibaba.fastjson.util.IdentityHashMap$Entry ...

  8. Layui + thymeleaf org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: " 错误解决

    解决方法: 1.将layui的代码移动到新的js文件当中,用template模板引擎的方式引入: <script th:src="@{/static/js/facility/mover ...

  9. java之hibernate之crud

    这篇文章主要讲解: 1>.对Hibernate使用的一些简单封装: · 2>.在单元测试中,使用Hibernate的封装的工具进行增删改查的测试 1.目录结构展示 2.代码展示 2.0 配 ...

  10. Mongodb 学习笔记(一)

    MongoDB 是一款开源.跨平台.分布式,具有大数据处理能力的文档存储数据库.在 2007 年由 MongoDB 软件公司开发完成,并实现全部代码源发展.目 前,该文档数据库被国内外众多知名网因所采 ...