postfix服務 配置

postfix(MTA)


郵件系統角色
1、MUA(郵件用戶代理) mail/mutt  foxmail  outlook  web
2、MTA(郵件傳輸代理)   exchange  notes  sendmail postfix qmail  
3、MDA(郵件分發代理 )


郵件應用協議
1、SMTP,簡單郵件傳輸協議,TCP 25端口,加密端口465,發郵件,一般工作在郵件服務器
2、POP3,第3版郵局協議,TCP 110端口,加密端口995接收郵件
3、IMAP4,第4版因特網消息訪問協議,TCP 143端口,加密端口993




發)[email protected] ---smtp---->(sina) ---smtp-----[google] {user02} ----pop3/imap4 (收)
      MUA        MTA          MDA     【MX】   MUA
      
      
測試郵件發送:


本機發送:
mail:(mail-->MTA(localhost:25)-->root@localhost-->/var/spool/mail/root)
# echo "123" | mail -s "a test mail" root@localhost


# sendmail a@localhost
hello,a.
test mail from sendmail.
.


網絡發送:
telnet:
telnet localhost 25 --訪問本機的郵件服務器
ehlo localhost --通告郵件服務器
mail from:root@localhost --發件人
rcpt to:a@localhost --收件人
data --郵件body
Subject:A Test Mail --主題
fdafdafdsa
fdafdfdsa
fdafdas --郵件的內容
. --結束




Postfix邏輯結構圖




說明:
1、橢圓形的圖標表示postfix程序
2、黃底方形的代表postfix的投遞目錄
3、藍底方形的代表在投遞過程中postfix進程調用外部的文件


結論:
1、postfix採用模塊化設計,流水線作業。
2、postfix可以通過兩種方式來接收郵件,一個本地(sendmail),另一個網絡(smtp)
3、有三個出口,分別是local,smtp,pipe


安裝postfix
1.如果有sendmail,需要先停掉舊的MTA
# service sendmail stop
# chkconfig sendmail off


2.安裝postfix
# yum -y install postfix


# rpm -ql postfix
/etc/pam.d/smtp.postfix --pam驗證設置,默認情況下postfix使用系統驗證
/etc/postfix --存放配置文件
/etc/postfix/access --smtp訪問控制
/etc/postfix/main.cf --主配置文件,postfix基本所有的配置都在此
/etc/postfix/master.cf --核心配置文件,實現郵件程序的調度
/sbin/ --postfix管理員命令(root)
/usr/libexec/postfix --所有用戶都能調用的命令
/var/spool/postfix --郵件投遞切換目錄
/etc/rc.d/init.d/postfix --啓動腳本










實例:
postfix(MTA smtp)+dovecot(pop3/imap)+squirrelmail(webmail)+apache+php+bind


確認的DNS的配置(MX記錄)/主機名,把郵件服務器的首選DNS指向正確的DNS服務器
# nslookup
> set type=mx
> baidu.com
Server:         192.168.0.39
Address:        192.168.0.39#53


baidu.com       mail exchanger = 5 mail.baidu.com.


配置主機名:
# hostname mail.baidu.com
# vim /etc/sysconfig/network
HOSTNAME=mail.baidu.com
# vim /etc/hosts
192.168.0.16            mail.baidu.com  baidu.com       mail


# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
home_mailbox = Maildir/ --郵箱的存儲格式,mailbox只有一個文件存儲郵件
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $mydomain, localhost
mydomain = baidu.com
myhostname = mail.baidu.com
mynetworks = 192.168.0.0/24
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
sample_directory = /usr/share/doc/postfix-2.3.3/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550

# service postfix restart
# chkconfig postfix on
# netstat -tnlp |grep :25 --postfix使用smtp協議




使用dovecot實現110/143收信
# yum -y install dovecot






# vim /etc/dovecot/conf.d/10-auth.conf --讓dovecot支持明文驗證
disable_plaintext_auth = no
(error    -ERR Plaintext authentication disallowed on non-secure (SSL/TLS) connections.    )




# service dovecot start
# chkconfig dovecot on
netstat -tlp|grep dove
tcp        0      0 *:imaps                     *:*                         LISTEN      21275/dovecot       
tcp        0      0 *:pop3s                     *:*                         LISTEN      21275/dovecot       
tcp        0      0 *:pop3                      *:*                         LISTEN      21275/dovecot       
tcp        0      0 *:imap                      *:*                         LISTEN      21275/dovecot       




# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK Dovecot ready.
user mail_a --使用mail_a登錄
+OK
pass 123 --密碼
+OK Logged in.
list --列出新郵件列表
+OK 1 messages:
1 499
.
retr 1 --讀取編號爲1的那封郵件.


2、使用outlook或者foxmail圖形客戶端來收取郵件








+++++++++++++++++++++++++++++++++++++
測試:


本地發送   echo "hello a"  | mail -s "a test mail from local" [email protected]


收信:1)$HOME/Maildir
         2) telnet localhost 110  user a pass 1   


網絡發送
[root@mail new]# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.baidu.com ESMTP Postfix
ehlo localhost
250-mail.baidu.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject: a test mail
hi b!....
.
250 2.0.0 Ok: queued as 513CD609B4
quit
221 2.0.0 Bye
Connection closed by foreign host.




收信
         1)$HOME/Maildir
         2) telnet localhost 110  user a pass 1   


[root@mail new]# telnet localhost 110
Trying ::1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user b
+OK
pass 1
+OK Logged in.
list
+OK 1 messages:
1 432
.
retr 1
+OK 432 octets
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from localhost (localhost [127.0.0.1])
by mail.baidu.com (Postfix) with ESMTP id 513CD609B4
for <[email protected]>; Thu, 13 Jun 2013 14:16:05 +0800 (CST)
subject: a test mail
Message-Id: <[email protected]>
Date: Thu, 13 Jun 2013 14:16:05 +0800 (CST)
From: [email protected]
To: undisclosed-recipients:;


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