Linux運維筆記-文檔總結-postfix郵件傳輸服務

以下所有操作都是在Red-hat 7.0上


postfix是Wietse Venema在IBM的GPL協議之下開發的MTA(郵件傳輸代理)軟件

postfix的郵件隊列(mail queues)
postfix有四種不同的郵件隊列,並且由隊列管理進程統一進行管理:
1. maildrop:本地郵件放置在maildrop中,同時也被拷貝到incoming中。
2. incoming:放置正在到達或隊列管理進程尚未發現的郵件。
3. active:放置隊列管理進程已經打開了並正準備投遞的郵件,該隊列有長度的限制。
4. deferred:放置不能被投遞的郵件。

|###########postfix基本介紹和配置##############|

1.基本介紹

postfix提供smtp協議用來投遞郵件

默認端口25

/var/log/maillog ##服務日誌

mail [email protected]

Subject: hello

hello world

. #用”.”來結束錄入內容併發送

mailq ##查看郵件隊列

postqueue -f ##重新處理郵件隊列

默認情況下郵件端口只在127.0.0.1上開啓 ##迴環接口上開啓

2.配置

在做實驗的時候要先配置好DNS,如果不懂DNS如何配置的,可以去看我的DNS配置文章.

vim /etc/postfix/main.cf

116 inet_interfaces = all ##25端口開啓的網絡接口

76 myhostname = westos-mail.westos.com ##指定mta主機名稱

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

99 myorigin = westos.com ##指定郵件來源結尾(@後面的字符內容)

164 mydestination = myhostname, mydomain, localhost ##接收郵件結尾字符的指定

systemctl restart postfix.service

systemctl stop firewalld ##做實驗要向外發送和接收郵件,所以要關閉火牆

DNS的配置
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述


|###########郵件別名和郵件羣發##############|

郵件別名的意思將自己的郵件名字改爲大家都知道的,默認的,比如admin

配置

vim /etc/aliases

別名: 真名 ##郵件別名

別名: :include:filename ##郵件羣發

vim filename

user1

user2

postalias /etc/aliases ##更新裏面的內容

這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述


|#########通過遠程主機測試郵件服務############|

Telnet協議是TCP/IP協議族中的一員,是Internet遠程登陸服務的標準協議和主要方式

這個程序要進行下載,yum install telnet -y

telnet 172.25.254.100 25   ##訪問100  25是端口號
Trying 172.25.254.100...
Connected to 172.25.254.100.
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:[email protected]    ##從westos上發送
250 2.1.0 Ok
rcpt to:[email protected]          ##在qq上接受
250 2.1.5 Ok
data                         ##編輯郵件內容
354 End data with <CR><LF>.<CR><LF>
adsf
asdf
asdf
.

這裏寫圖片描述
這裏寫圖片描述


|#########郵件客戶端的訪問控制############|

這個訪問就是讓客戶端(比如172.25.254.10這個客戶端)拒絕登入

在mta(郵件傳輸代理)上

如果感覺這些參數太長記不住,可以先查詢,直接複製粘貼。postconf -d | grep postfix,然後再裏面找,只要記個大概的參數就可以了

postconf -e “smtpd_client_restrictions = check_client_access hash:/etc/postfix/access”

vim /etc/postfix/access

172.25.254.22 REJECT ##拒絕22這個主機

postmap /etc/postfix/access ##對這個文件進行加密

systemctl restart postfix

測試

先登入22這個主機上再進行測試:
[root@foundation22 ~]# telnet 172.25.254.100 25
Trying 172.25.254.100...
Connected to 172.25.254.100.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <unknown[172.25.254.22]>: Client host rejected: Access denied

這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述


|##########限制用戶發送###########|

postconf -e “smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender”

vim /etc/postfix/sender

[email protected] REJECT

postmap /etc/postfix/sender ##對這個文件進行加密

systemctl restart postfix

測試

[kiosk@foundation0 Desktop]$ telnet 172.25.254.100 25
Trying 172.25.254.100...
Connected to 172.25.254.100.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <[email protected]>: Sender address rejected: Access denied

![這裏寫圖片描述](https://img-blog.csdn.net/20170524185202246?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTmluZ2RheGluZzE5OTQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![這裏寫圖片描述](https://img-blog.csdn.net/20170524185229962?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTmluZ2RheGluZzE5OTQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![這裏寫圖片描述](https://img-blog.csdn.net/20170524185318919?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTmluZ2RheGluZzE5OTQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)

|##########限制用戶接收###########|

postconf -e “smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip”

vim /etc/postfix/recip

[email protected] REJECT

postmap /etc/postfix/recip ##對這個文件進行加密

systemctl restart postfix

測試

[kiosk@foundation0 Desktop]$ telnet 172.25.254.100 25
Trying 172.25.254.100...
Connected to 172.25.254.100.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:westos@westos.com
250 2.1.0 Ok
rcpt to:root@westos.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
adsf
adsf
asdf
.
250 2.0.0 Ok: queued as DE17D2461EA
qiut
502 5.5.2 Error: command not recognized
mail from:root@westos.com
250 2.1.0 Ok
rcpt to:westos@westos.com
554 5.7.1 <westos@westos.com>: Recipient address rejected: Access denied

這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述


|##########出站地址僞裝###########|

出戰地址僞裝就是不想讓別人知道發件人是誰,而採取的一種方式

postconf -e “smtp_generic_maps = hash:/etc/postfix/generic”

vim /etc/postfix/generic

[email protected] [email protected] ##將westos的地址僞裝成sb.com

postmap /etc/postfix/generic ##對其加文件加密

systemctl restart postfix

測試

測試
su - westos
mail root@qq.com

這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述


|##########入戰地址轉換###########|

在某些主機想將僞裝的地址變換回來成原始的,就要用地址轉換了

dns mx解析要先做好,gay.com

postconf -e “virtual_alias_maps = hash:/etc/postfix/virtual”

/etc/postfix/virtual

虛擬名字 真實用戶

[email protected] [email protected]

postmap /etc/postfix/virtual ##對其加密

systectl restart postfix

測試

測試
mail hello@sb.com

這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述


|########## dovecot+mutt###########|

Dovecot 是一個開源的 IMAP 和 POP3 郵件服務器,是收件箱

1.dovecot 用來提供收件協議

pop3 110

imap 143

imaps 993

pop3s 995

給定用戶名稱,用戶密碼,dovecot程序代我們去看這個用戶的郵件文件

2.安裝

yum install dovecot -y

yum install mutt -y ##管理顯示email的程序

3.配置

vim /etc/dovecot/dovecot.conf

24 protocols = imap pop3 lmtp ##協議

48 login_trusted_networks = 0.0.0.0/0 ##允許任何人登入

49 disable_plaintext_auth = no ##允許明文密碼驗證

vim /etc/dovecot/conf.d/10-mail.conf

30 mail_location = mbox:~/mail:INBOX=/var/mail/%u

[westos@westos-mail ~]$ mkdir mail/.imap/ -p ##創建這個用戶後,必須創建這個目錄和文件,不然不能顯示。

[westos@westos-mail ~]$ touch mail/.imap/INBOX

mkdir /etc/skel/mail/.imap/ -p ##/etc/skel這個文件夾的作用就是按照後面mail/.imap/INBOX自動建立

touch /etc/skel/mail/.imap/INBOX

測試

mutt -f pop://westos@172.25.254.10  ##登入email收件箱

這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述


|########## 用雷鳥應用程序查收郵件###########|

1.安裝雷鳥程序**

2.直接進入程序進行登陸**

這裏寫圖片描述
這裏寫圖片描述

接下來會出現這個:

這裏寫圖片描述
這裏寫圖片描述
這裏寫圖片描述


The end

發佈了86 篇原創文章 · 獲贊 102 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章