postfix 邮件1

简介:

spacer.gif

spacer.gif

######邮件部分######

 

前提

1.保证环境的纯净

wKioL1kkWW3SKOU-AAAJHOwTDro116.png-wh_50

 

2.dns的配置

 

*此处关于dns不做解释,可参照之前dns博客理解


[root@westos-mail ~]# yum install bind -y

 wKioL1kkWaHRY_fNAAAKH8XQBwg788.png-wh_50

[root@westos-mail ~]# systemctl start named

 

[root@westos-mail ~]# vim /etc/named.conf

wKiom1kkWcDiv0x-AAAIYyXT6Uw142.png-wh_50 

 

[root@westos-mail ~]# vim /etc/named.rfc1912.zones  

 wKiom1kkWdvAZy76AAAFt95OjM8424.png-wh_50

[root@westos-mail ~]# cd /var/named/

[root@westos-mail named]# ls

data     named.ca     named.localhost  slaves

dynamic  named.empty  named.loopback

[root@westos-mail named]# cp -p named.localhost westos.com.zone

[root@westos-mail named]# vim westos.com.zone

wKioL1kkWjKjk5pSAAAE56M7c48699.png-wh_50

 

[root@westos-mail named]# cp -p westos.com.zone qq.com.zone

[root@westos-mail named]# vim qq.com.zone

wKiom1kkWkqxI7n3AAAEcqo0UsU224.png-wh_50                                                 

[root@westos-mail named]# systemctl restart named

[root@westos-mail named]# systemctl stop firewalld

[root@westos-mail named]# systemctl disable firewalld  ##不关闭火墙,其他人不能dig到

rm '/etc/systemd/system/basic.target.wants/firewalld.service'

rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'

[root@westos-mail named]# vim /etc/resolv.conf

wKioL1kkWmTDIJTpAAAGF2dWPdo071.png-wh_50 


[root@westos-mail named]# dig -t mx westos.com

wKioL1kkWoGTRlIaAAAGUUiBE44840.png-wh_50 

[root@westos-mail named]# dig -t mx qq.com

wKioL1kkWpijd_ZpAAAGyN7r2c8836.png-wh_50

 

######postfix#####

1.基本定义

postfix提供smtp协议用来投递邮件

默认端口25

 

[root@westos-mail named]# mail root@qq.com

Subject: w

wq

.    ##用“.”来结束录入内容并发送

EOT

 

   ##默认情况下邮件端口只在127.0.0.1上开启

[root@westos-mail named]# netstat -antlpe | grep master

tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      0          21046      1378/master         

tcp6       0      0 ::1:25                  :::*                    LISTEN      0          21047      1378/master         

***邮件日志存储地址   /var/log/maillog

 

mail        ##邮件查看

mailq       ##查看邮件队列

postqueue -f    ##重新处理邮件队列 

 

 

2.配置

[root@westos-mail named]# vim /etc/postfix/main.cf

76 myhostname = westos-mail.westos.com    ##指定mta主机名称

83 mydomain = westos.com        ##指定mta的域名

99 myorigin = $mydomain         ##指定邮件来源结尾(@后面的字符内容)

116 inet_interfaces = all     ##25端口开启的网络端口

164 mydestination = $myhostname, $mydomain, localhost    ##接收邮件结尾字符的指定

 

[root@westos-mail named]# systemctl restart postfix.service

[root@westos-mail named]# systemctl stop firewalld

 

 

  ##更改后:

[root@westos-mail named]# netstat -antlpe | grep master

tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      0          110726     928/master          

tcp6       0      0 :::25                   :::*                    LISTEN      0          110727     928/master          

 

 

3.邮件别名与群发

 

[root@westos-mail named]# vim /etc/aliases

 97 admin:          root        ##邮件别名(用admin发送但是接收端显示的是root)

 98 moreuser:       :include:/etc/postfix/moreuser   ##邮件群发

 

[root@westos-mail named]# vim /etc/postfix/moreuser

  1 student

  2 root

~                                                  

[root@westos-mail named]# postalias /etc/aliases   ##立即生效

 

测试:

1)别名测试

[root@qq-mail ~]# mail admin@westos.com     发送端)

Subject: wq

wq

wq

wq

.

EOT

 

 

[root@westos-mail named]# mail        接收端)

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/spool/mail/root": 1 message 1 new

>N  1 root                  Sat May 20 04:13  24/859   

& 1

Message  1:From root@qq.com  Sat May 20 04:11:21 2017

Return-Path: <root@qq.com>

X-Original-To: admin@westos.com

Delivered-To: admin@westos.com

Date: Sat, 20 May 2017 04:11:21 -0400

To: admin@westos.com

Subject: wq

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

From: root@qq.com (root)

Status: RO

 

wq

wq

wq

 

& q

 

2)群发测试

[root@qq-mail ~]# mail moreuser@westos.com     发送端)

Subject: wqq

hahaha

.

EOT

[root@qq-mail ~]# mailq

Mail queue is empty

[root@westos-mail named]# mail  接收端)

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/spool/mail/root": 1 message 1 new

>N  1 root                  Sat May 20 04:13  24/859   

& 1

Message  1:

From root@qq.com  Sat May 20 04:13:15 2017

Return-Path: <root@qq.com>

X-Original-To: moreuser@westos.com

Delivered-To: root@westos.com

Delivered-To: moreuser@westos.com

Date: Sat, 20 May 2017 04:13:15 -0400

To: moreuser@westos.com

Subject: wqq

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

From: root@qq.com (root)

Status: R

 

hahaha

 

& q

Held 1 message in /var/spool/mail/root

[root@westos-mail named]# mail -u student

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/mail/student": 1 message 1 new

>N  1 root                  Sat May 20 04:13  24/862   

& 1

Message  1:

From root@qq.com  Sat May 20 04:13:15 2017

Return-Path: <root@qq.com>

X-Original-To: moreuser@westos.com

Delivered-To: student@westos.com

Delivered-To: moreuser@westos.com

Date: Sat, 20 May 2017 04:13:15 -0400

To: moreuser@westos.com

Subject: wqq

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

From: root@qq.com (root)

Status: R

 

hahaha

 

& q

Held 1 message in /var/mail/student

 

 

 

 

 

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

[root@foundation13 kiosk]#  yum install telent -y   ##安装服务

 

[root@foundation13 kiosk]# telnet 172.25.254.113 25   ##连接113主机的25端口

Trying 172.25.254.113...

Connected to 172.25.254.113.

Escape character is '^]'.

220 westos-mail.westos.com ESMTP Postfix

ehlo hello    ##打招呼,查看是否回应

250-westos-mail.westos.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from:root@westos.com   ##邮件来源

250 2.1.0 Ok

rcpt to:root@qq.com    ##邮件去向

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

wq          ##邮件内容

haha

lalala

.

250 2.0.0 Ok: queued as E2A022461FD

 

测试端:

[root@qq-mail ~]# mail

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/spool/mail/root": 4 messages 1 new 3 unread

    1 root                  Sat May 20 03:46  22/730   

 U  2 Mail Delivery System  Sat May 20 04:12  76/2389  

 U  3 Mail Delivery System  Sat May 20 04:12  76/2389  

>N  4 root@westos.com       Sat May 20 04:38  15/493   

& 4

Message  4:

From root@westos.com  Sat May 20 04:38:35 2017

Return-Path: <root@westos.com>

X-Original-To: root@qq.com

Delivered-To: root@qq.com

Status: R

 

wq

haha

lalala

 

& q

Held 4 messages in /var/spool/mail/root

You have mail in /var/spool/mail/root

[root@qq-mail ~]#

 

 

 

5.邮件客户端的访问控制

##限制客户端

mta上

[root@westos-mail ~]# postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"  ##用参数检测此文件使其识别文件内容

 

[root@westos-mail ~]# vim /etc/postfix/main.cf  ##自动生成在文件末尾

680 smtpd_client_restrictions = check_client_access hash:/etc/postfix/access

 

[root@westos-mail ~]# vim /etc/postfix/access

477 172.25.254.13 REJECT

 

[root@westos-mail ~]# postmap /etc/postfix/access    ##加密

[root@westos-mail ~]# cd /etc/postfix/

[root@westos-mail postfix]# ls    ##access.db即位加密文件

access     generic        master.cf  transport

access.db  header_checks  moreuser   virtual

canonical  main.cf        relocated

 

[root@westos-mail postfix]# systemctl restart postfix.service

  

测试:

实验前:

[root@foundation13 kiosk]# telnet 172.25.254.113 25

Trying 172.25.254.113...

Connected to 172.25.254.113.

Escape character is '^]'.

220 westos-mail.westos.com ESMTP Postfix

mail from:root@westos.com

250 2.1.0 Ok

rcpt to:root@qq.com

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

wq

haha

lalala

.

250 2.0.0 Ok: queued as E2A022461FD

Connection closed by foreign host.    ##连接成功

实验后:

[root@foundation13 kiosk]# telnet 172.25.254.113 25

Trying 172.25.254.113...

Connected to 172.25.254.113.

Escape character is '^]'.

220 westos-mail.westos.com ESMTP Postfix

mail from:root@westos.com

250 2.1.0 Ok

rcpt to:root@qq.com

554 5.7.1 <unknown[172.25.254.13]>: Client host rejected: Access denied    ##连接被拒

本文转自AELY木博客51CTO博客,原文链接http://blog.51cto.com/12768057/1928817如需转载请自行联系原作者


AELY木

相关文章
|
网络协议 Linux 文件存储
Postfix 邮件服务器的配置
Postfix是一种功能强大且功能多样的邮件传输代理。在本文中,我们已经了解了如何使用postfix 和 dovecot为基于系统用户帐户的单个域实现基本电子邮件服务器。我们几乎没有涉及基于 postfix 的系统的真正功能,但希望能为新用户构建提供坚实的工作基础。
1736 0
|
存储 网络协议 Linux
Postfix + Extmail 企业邮件服务器搭建
ExtMail套件用于提供从浏览器中登录、使用邮件系统的Web操作界面,而Extman套件用于提供从浏览器中管理邮件系统的Web操作界面。它以GPL版权释出,设计初衷是希望设计一个适应当前高速发展的IT应用环境,满足用户多变的需求,能快速进行开发、改进和升级,适应能力强的webmail系统。
Postfix + Extmail 企业邮件服务器搭建
|
网络协议 Linux 网络安全
Linux服务器---邮件服务安装postfix
安装postfix      postfix是一个快速、易于管理、安全性高的邮件发送服务,可以配合dovecot实现一个完美的邮箱服务器。1、安装postfix       [root@localhost ~]# rpm -qa | grep postfix      [root@localhos...
2379 0
|
开发工具 网络安全 数据安全/隐私保护
Postfix 邮件服务器安装与配置
#!/bin/bash yum -y install postfix dovecot; #/etc/postfix/main.cf #postfix check  postfix start  postfix stop postfix flush  postfixreload #/etc/postfix/main.
1305 0
|
网络协议 测试技术 开发工具
|
网络协议 测试技术 数据安全/隐私保护
|
测试技术 开发工具 数据安全/隐私保护
|
网络协议 安全 关系型数据库
|
Linux 开发工具 数据安全/隐私保护