天天看點

菜鳥學Linux 第060篇筆記 mail server概念,postfix 編譯

菜鳥學Linux 第060篇筆記 mail server概念,postfix 編譯

Mail Server

TLS: Transport Layer Security

SMTP: Simple Mail Transfer Protocol

ESMTP: Extended Simple Mail Transfer Protocol

POP3: Post Office Protocol vertion 3

IMAP4: Internet Mail Access Protocol (消耗資源大,但功能也相對強)

UUCP: Unix to Unix CoPy

Unix 主機複制檔案的協定

SMTP: (25/tcp)

C/S 

郵件傳輸 MT (Mail Transfer)

郵件投遞 MD (Mail Delivery)

郵件使用者 MU (Mail User)

郵件使用者代理 MUA (Mail User Agent)

郵件傳輸代理 MTA (Mail Transfer Agent)

郵件投遞代理 MDA (Mail Delivery Agent)

郵件取回代理 MRA (Mail Retrieval Agent)

MUA 從 MRA 取郵件 用 POP3 or IMAP4

LMTP Local Mail Transfer Protocol

smtpd

SMTP Simple Mail Transfer Protocol

郵件傳遞過程

MUA --> smtp --> SMTPD --> smtp --> SMTPD --> MDA --> MUA

Open Relay: 開放式中繼 (一般不允許中繼)

SASL:  Simple Authentication Secure Layer 簡單認證安全層 協定

WebMail 

LDAP: Lightweight Directory Access Protocol

是一個可以提供快速檢索的協定,比mysql檢索的速度快10倍

缺點 寫的速度慢

虛拟使用者 僅用于通路某服務的數字辨別

使用者: 字元串 憑證(加密存放)

組建軟體

MTA 郵件傳輸代理 Mail Transfer Agent  SMTP伺服器  (實作的軟體)

sendmail, uucp

單體結構, SUID, 配置檔案文法不好了解(m4編寫)

qmail

postfix 子產品化設計,安全,跟sendmail相容,效率高

exim

Exchange (Windows, 異步消息協作平台)

SASL: v2

cyrus-sasl(saslauthd) 架構

courier-authlib

MDA 郵件投遞代理 Mail Delivery Agent

procmail (sendmail)

maildrop

MRA 郵件取回代理 Mail Retrieval Agent (pop3, imap4) 實作軟體

cryus-imap

dovecot

MUA 郵件使用者代理 Mail User Agent

Outlook Express, Outlook

Foxmail

Thunderbird

Evolution

mutt(文本界面)

WebMail

Openwebmail   (perl)

Squirrelmail  (php)

Extmail (Extman管理元件) (perl)

EOS(Extmail OS), CentOS

郵件伺服器布署

Postfix + SASL (courier-authlib) 發郵件

Dovecot + MySQL 收郵件

Webmail: Extmail + Extman + httpd

postfix: rpm 包不支援虛拟使用者

1. 布署postfix

# service sendmail stop

# chkconfig sendmail off

# rpm -e --nodeps sendmail

確定linux系統裡已經安裝了MySQL 前邊章節有,這裡不再詳解其安裝過程

# groupadd -g 2525 postfix

# useradd -g 2525 -u 2525 -M -s /sbin/nologin postfix

# groupadd -g 2526 postdrop

# useradd -g 2526 -u 2526 -M -s /sbin/nologin postdrop

# make makefiles 'CCARGS=-DASH_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH 

-DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 

'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/lib/sasl2 

-lsasl2 -lssl -lcrypto' (此為一行指令)

# make

# make install

啟動postfix

# postfix start

postfix 配置檔案:

postfix子產品化:

master: /etc/postfix/master.cf

mail: /etc/postfix/main.cf

參數 = 值  (參數必須寫在行的絕對行首,以空白開頭的行被認為是上一行的延續)

postconf (Postfix configuration utility) 

-d     Print main.cf  default  parameter  settings  instead  of

   actual  settings.   Specify  -df  to fold long lines for

   human readability (Postfix 2.9 and later).

-n     Show only configuration parameters  that  have  explicit

           name=value  settings  in  main.cf.   Specify -nf to fold

           long  lines  for  human  readability  (Postfix  2.9  and

           later).

-m     List  the  names of all supported lookup table types. In

           Postfix configuration files, lookup tables are specified

           as  type:name,  where  type  is  one of the types listed

           below. The table name syntax depends on the lookup table

           type as described in the DATABASE_README document.

-A     List the available SASL client plug-in types.  The  SASL

           plug-in  type  is  selected  with  the smtp_sasl_type or

           lmtp_sasl_type configuration  parameters  by  specifying

           one of the names listed below.

           cyrus  This  client plug-in is available when Postfix is

                  built with Cyrus SASL support.

-e     Edit the main.cf configuration file, and update  parame-

           ter  settings  with  the "name=value" pairs on the post-

           conf(1) command line.

smtp狀态碼

1xx 純資訊

2xx 正确

3xx 上一步操作尚未完成,需要繼續補充

4xx 暫時性錯誤

5xx 永久性錯誤

smtp協定原語(指令)telnet localhost 25

helo (smtp協定) hostname

ehlo (esmtp協定) hostname

mail from: root

rcpt to  (recipient 接受方)

data

.

alias: 郵件别名

[email protected]: [email protected]

/etc/aliases --> hash --> /etc/aliases.db

# newaliases

postfix預設把本機的IP位址所在的網段識别為本地網絡,并且為之中繼郵件;

本文轉自Winthcloud部落格51CTO部落格,原文連結http://blog.51cto.com/winthcloud/1886015如需轉載請自行聯系原作者

Winthcloud

繼續閱讀