第七题 配置邮件服务器

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] 313. Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  2. SpringBoot系列教程JPA之新增记录使用姿势

    SpringBoot系列教程JPA之新增记录使用姿势 上一篇文章介绍了如何快速的搭建一个JPA的项目环境,并给出了一个简单的演示demo,接下来我们开始业务教程,也就是我们常说的CURD,接下来进入第 ...

  3. mysql创建用户并授权Repl_slave_priv和Repl_client_priv

    CREATE USER 'test'@'localhost' IDENTIFIED BY 'test'; FLUSH PRIVILEGES; GRANT REPLICATION CLIENT ON * ...

  4. 百度地图jsapi 自定义大头针的方法

    百度地图jsapi 自定义大头针的方法<pre> var myIcon = new BMap.Icon("http://developer.baidu.com/map/jsdem ...

  5. 如何在Linux中结合示例使用'cat'和'tac'命令

    上一篇我们讲到了cat的使用示例:https://www.cnblogs.com/WeiLian1024/p/11863057.html 本篇我们将继续延续Cat讲讲Tac 本文是我们讲讲Linux技 ...

  6. GIT 基础 &本地服务器搭建

    Git是一款免费.开源的分布式版本控制系统.众所周知的Github便是基于Git的开源代码库以及版本控制系统,由于其远程托管服务仅对开源免费,所以搭建本地Git服务器也是个较好的选择,本文将对此进行详 ...

  7. libevent实现对管道的读写操作

    读管道: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/t ...

  8. python 之 前端开发( jQuery事件、动画效果、.each()、 .data())

    11.58 事件 11.581 事件绑定方法与解绑 绑定事件: // 绑定方式一: $('.box1').click(function () { alert('绑定方式一') }); ​ // 绑定方 ...

  9. 【LEETCODE】35、169题, Majority Element

    package y2019.Algorithm.array; import java.util.HashMap; import java.util.Map; /** * @ProjectName: c ...

  10. Java线程的等待与唤醒完整示例代码

    项目结构: 资源类: 输入线程:  输出线程: 测试: 人妖问题发生: 线程安全问题的解决方法: 调用Object的wait()和notify()方法时需注意:必须是锁对象方可调用,否则将抛出无效的监 ...