linux server postfix服務配置 postfix(MTA) 郵件系統角色1、MUA(郵件使用者代理) mail/mutt foxmail outlook web2、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 發)user01@sina.com.cn ---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@localhosthello,a.test mail from sendmail.. 網路發送:telnet:telnet localhost 25 --訪問原生郵件伺服器ehlo localhost --通告郵件伺服器mail from:root@localhost --寄件者rcpt to:a@localhost --收件者data --郵件bodySubject:A Test Mail --主題fdafdafdsa fdafdfdsafdafdas --郵件的內容. --結束 Postfix邏輯結構圖 說明:1、橢圓形的表徵圖表示postfix程式2、黃底方形的代表postfix的投遞目錄3、藍底方形的代表在投遞過程中postfix進程調用外部的檔案 結論:1、postfix採用模組化設計,流水線作業。2、postfix可以通過兩種方式來內送郵件,一個本地(sendmail),另一個網路(smtp)3、有三個出口,分別是local,smtp,pipe 安裝postfix1.如果有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.comServer: 192.168.0.39Address: 192.168.0.39#53 baidu.com mail exchanger = 5 mail.baidu.com. 配置主機名稱:# hostname mail.baidu.com# vim /etc/sysconfig/networkHOSTNAME=mail.baidu.com# vim /etc/hosts192.168.0.16 mail.baidu.com baidu.com mail # postconf -nalias_database = hash:/etc/aliasesalias_maps = hash:/etc/aliasescommand_directory = /usr/sbinconfig_directory = /etc/postfixdaemon_directory = /usr/libexec/postfixdebug_peer_level = 2home_mailbox = Maildir/ --郵箱的儲存格式,mailbox只有一個檔案儲存體郵件html_directory = noinet_interfaces = allmail_owner = postfixmailq_path = /usr/bin/mailq.postfixmanpage_directory = /usr/share/manmydestination = $mydomain, localhostmydomain = baidu.commyhostname = mail.baidu.commynetworks = 192.168.0.0/24myorigin = $mydomainnewaliases_path = /usr/bin/newaliases.postfixqueue_directory = /var/spool/postfixreadme_directory = /usr/share/doc/postfix-2.3.3/README_FILESsample_directory = /usr/share/doc/postfix-2.3.3/samplessendmail_path = /usr/sbin/sendmail.postfixsetgid_group = postdropunknown_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 onnetstat -tlp|grep dovetcp 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 110Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.+OK Dovecot ready.user mail_a --使用mail_a登入+OKpass 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" a@baidu.com 收信:1)$HOME/Maildir 2) telnet localhost 110 user a pass 1 網路發送[root@mail new]# telnet localhost 25Trying ::1...telnet: connect to address ::1: Connection refusedTrying 127.0.0.1...Connected to localhost.Escape character is '^]'.220 mail.baidu.com ESMTP Postfixehlo localhost250-mail.baidu.com250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-ENHANCEDSTATUSCODES250-8BITMIME250 DSNmail from:a@baidu.com250 2.1.0 Okrcpt to:b@baidu.com250 2.1.5 Okdata354 End data with <CR><LF>.<CR><LF>subject: a test mailhi b!.....250 2.0.0 Ok: queued as 513CD609B4quit221 2.0.0 ByeConnection closed by foreign host. 收信 1)$HOME/Maildir 2) telnet localhost 110 user a pass 1 [root@mail new]# telnet localhost 110Trying ::1...Connected to localhost.Escape character is '^]'.+OK Dovecot ready.user b+OKpass 1+OK Logged in.list+OK 1 messages:1 432.retr 1+OK 432 octetsReturn-Path: <a@baidu.com>X-Original-To: b@baidu.comDelivered-To: b@baidu.comReceived: from localhost (localhost [127.0.0.1])by mail.baidu.com (Postfix) with ESMTP id 513CD609B4for <b@baidu.com>; Thu, 13 Jun 2013 14:16:05 +0800 (CST)subject: a test mailMessage-Id: <20130613061622.513CD609B4@mail.baidu.com>Date: Thu, 13 Jun 2013 14:16:05 +0800 (CST)From: a@baidu.comTo: undisclosed-recipients:; hi b!....