|
|
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已! |
|
恭喜您是本站第 1729362
位訪客!
登入 | 註冊
|
|
|
|
發表者 |
討論內容 |
冷日 (冷日) |
發表時間:2012/11/29 5:03 |
- Webmaster

- 註冊日: 2008/2/19
- 來自:
- 發表數: 15771
|
- [轉貼]Postfix的配置文件和主要命令
- [原]Postfix的配置文件和主要命令
熟悉postfix中的一些命令,對於今後的維護是很必要的。接下來會分析其中一些重要的配置文件和相關命令。
一、總體說明
這是postfix的主配置文件,幾乎所有的配置都在這裡設定。設定完畢後,需要用reload或restart重新讀取配置信息。(涉及網絡的配置,需要使用restart)
這個是postfix子程序的運行狀態設置,例如是否使用chroot等。
類似黑白名單的作用,設置完畢後,需要在main.cf中激活,並使用postmap生成相關的數據庫。
別名的設置目錄,同樣,需要在main.cf中激活,並使用postalias生成相關數據庫。
二、main.cf文件 該文件的配置比較規範,文件中也帶了很詳細的幫助說明。其主要包括幾部分: 1、「#」號開頭,表示改行是註釋; 2、可以使用下面的形式給變量定義:
引用 變量 = 值
請注意等號兩邊需要留一空格。並且變量最好符合Bash的規範。 3、可以使用「$變量」來引用該變量的值; 例如 myorigin = $myhostname,會等於 myorigin = linuxfly.org; 4、如果變量使用兩個以上的數據,可以用空格符或逗號來分隔,設置跨行也可以; 例如:
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
也可以寫為:
mydestination = $myhostname localhost.$mydomain localhost $mydomain
或:
mydestination = $myhostname,
localhost.$mydomain,
localhost,
$mydomain
結果是相同的。 5、可以使用hash等格式進行更規範的設定; 例如:
alias_maps = hash:/etc/aliases
那麼,相關的值就可以寫入/etc/aliases文件中。 6、若重複設定某一變量的設定,則以最後出現的設定值為準!
三、/etc/postfix/access文件 1、需要在main.cf中打開
/etc/postfix/main.cf:
smtpd_client_restrictions = check_client_access hash:/etc/postfix/access
2、設定值 例如:
/etc/postfix/access:
192.168.228.10 REJECT
192.168.228.1 OK
linuxfly.org OK
3、生成數據庫
# postmap hash:/etc/postfix/access
四、/etc/aliases文件 1、同樣需要在main.cf中打開
/etc/postfix/main.cf:
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
2、設定值
/etc/aliases:
mailer-daemon: postmaster
postmaster: root
root: linuxing,root
前面是鍵值,後面是真實的值。真實的值不要求是本地郵件,也可以是外面的郵箱,例如:linuxing@163.com等。 3、生成數據庫
# postalias hash:/etc/aliases
※這會生成類似.db的數據庫文件,主要是為了讓postfix能快速的讀取。其他可以使用多值的地方也可以該方式定義。默認會自動識別,但也可以用「hash:文件」指定格式。 4、若是個人用戶,可以設置主目錄下的~/.forward文件,也可以設置別名,一行一個Email地址,例如:
[linuxing@dc5test ~]$ cat .forward
test
test@test.com
[linuxing@dc5test ~]$ chmod 644 .forward
權限不要搞錯了!
五、postfix主要命令 1、查看配置信息
[root@dc5test postfix]# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = $myhostname, localhost
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = linuxfly.cn
mynetworks = 192.168.218.0/24, 127.0.0.0/8
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.1.5/README_FILES
relay_domains = $mydestination
sample_directory = /usr/share/doc/postfix-2.1.5/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
unknown_local_recipient_reject_code = 550
2、查看隊列信息
# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
DB7678DA5 289 Wed Aug 22 16:46:28 root@linuxfly.org
(Host or domain name not found. Name service error for name=linuxfly.org type=MX: Host not found, try again)
root@linuxfly.org
-- 0 Kbytes in 1 Request.
或
# postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
DB7678DA5 289 Wed Aug 22 16:46:28 root@linuxfly.org
(Host or domain name not found. Name service error for name=linuxfly.org type=MX: Host not found, try again)
root@linuxfly.org
-- 0 Kbytes in 1 Request.
結果是一樣的。 3、強制發出郵件
或
這會把隊列中的郵件再發一次。可以處理一些臨時的錯誤問題。 4、查看在發郵件信息 在發的郵件會放在/var/spool/postfix/deferred目錄中,但其中含有一些postfix特定字符,可通過postcat查看:
# postcat DB7678DA5
*** ENVELOPE RECORDS DB7678DA5 ***
message_size: 289 163 1 0
message_arrival_time: Wed Aug 22 16:46:28 2007
named_attribute: message_origin=local
sender_fullname: root
sender: root@linuxfly.org
original_recipient: root@linuxfly.org
recipient: root@linuxfly.org
*** MESSAGE CONTENTS DB7678DA5 ***
Received: by dc5test.linuxfly.org (Postfix, from userid 0)
id DB7678DA5; Wed, 22 Aug 2007 16:46:28 +0800 (CST)
To: root@linuxfly.org
Subject: test
Message-Id: <20070822084628.DB7678DA5@dc5test.linuxfly.org>
Date: Wed, 22 Aug 2007 16:46:28 +0800 (CST)
From: root@linuxfly.org (root)
*** HEADER EXTRACTED DB7678DA5 ***
*** MESSAGE FILE END DB7678DA5 ***
5、一些Email測試用命令 ◎mail,字符下的客戶端
$ mail -s 'subject' linuxing < ~/file
把file中的內容作為郵件內容,以subject做標題,發給本地的linuxing用戶。
$ mail -s 'subject' linuxing
test
Ctrl-D保存退出
Cc: root
●mail直接回車 則是作為本地的郵件接收客戶端,可以用d刪除,回車查看,序號查看,help幫助或q退出等操作。
# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 2 messages 2 unread
>U 1 root@linuxfly.org Tue Aug 21 11:56 94/2251 "LogWatch for dc5test"
U 2 root@linuxfly.org Tue Aug 21 11:57 23/846 "Anacron job 'cron.daily'"
●使用mail發送附件
# uuencode /root/install.log install.log|mail -s 'install log' linuxing
uuencode後第一個參數的本地文件,第二個參數是郵件中的附件名稱。 ●字符下收信:
$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/linuxing": 1 message 1 new
>N 1 root@linuxfly.org Wed Aug 22 17:10 853/52344 "install log"
& s 1 install.log
"install.log" [New file]
& exit
會保存為install.log文件,然後再解壓出來:
$ uudecode install.log -o install.log
uudecode: install.log: Short file
◎telnet,測試smtp和pop3服務 ●smtp服務
# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 dc5test.linuxfly.org ESMTP Postfix
ehlo localhost
250-dc5test.linuxfly.org
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5 NTLM LOGIN GSSAPI PLAIN
250-AUTH=DIGEST-MD5 CRAM-MD5 NTLM LOGIN GSSAPI PLAIN
250 8BITMIME
mail from:"root"<root@linuxfly.org>
250 Ok
rcpt to:<linuxing@linuxfly.org>
250 Ok
data
354 End data with <CR><LF>.<CR><LF>
A test mail.
.
250 Ok: queued as A27B38DAF
quit
221 Bye
Connection closed by foreign host.
※內容後的「.」號表示內容的終結符。 ●pop3服務
# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK dovecot ready.
user linuxing
+OK
pass password
+OK Logged in.
list
+OK 1 messages:
1 576
.
retr 1
+OK 576 octets
Return-Path: <root@linuxfly.org>
X-Original-To: linuxing
Delivered-To: linuxing@linuxfly.org
Received: by dc5test.linuxfly.org (Postfix, from userid 0)
id D6D728DB4; Wed, 22 Aug 2007 17:28:33 +0800 (CST)
To: linuxing@linuxfly.org
Subject: subject
Message-Id: <20070822092833.D6D728DB4@dc5test.linuxfly.cn>
Date: Wed, 22 Aug 2007 17:28:33 +0800 (CST)
From: root@linuxfly.org (root)
X-IMAPbase: 1187497071 28
Status: O
X-UID: 28
Content-Length: 13
X-Keywords:
A test mail.
.
quit
+OK Logging out.
Connection closed by foreign host.
※telnet和mail命令雖然麻煩,但確實最簡單的流程認證方式。在排錯的時候非常重要。
原文出處:[原]Postfix的配置文件和主要命令 - linuxの飘扬 - Power by www.linuxfly.org
|
|
討論串
-
[轉貼]建置 POSTFIX 伺服器 (冷日 (冷日), 2009/3/24 6:20)
-
[轉貼]建置 POSTFIX 伺服器(壹~叁章) (冷日 (冷日), 2009/3/24 6:27)
-
[轉貼]建置 POSTFIX 伺服器(肆~陸章) (冷日 (冷日), 2009/3/24 6:30)
-
[轉貼]建置 POSTFIX 伺服器(柒~玖章) (冷日 (冷日), 2009/3/24 6:32)
-
[轉貼]建置 POSTFIX 伺服器(拾章) (冷日 (冷日), 2009/3/24 6:34)
-
[轉貼]Postfix + Amavisd-new + SpamAssassin + ClamAV (冷日 (冷日), 2009/3/25 8:29)
-
[轉貼]Postfix + Amavisd-new + SpamAssassin + ClamAV (冷日 (冷日), 2009/3/25 8:47)
- »
[轉貼]Postfix的配置文件和主要命令 (冷日 (冷日), 2012/11/29 5:03)
-
[轉貼]postfix基本配置和設定DNS (冷日 (冷日), 2012/11/29 5:06)
-
[轉貼]Postfix設定檔中文說明 (冷日 (冷日), 2012/11/29 5:09)
-
[轉貼]CentOS 6.3 Mail Server 設定筆記 (冷日 (冷日), 2014/8/13 4:32)
-
[轉貼]centos 6.5 mail server note (冷日 (冷日), 2014/8/13 4:49)
-
[分享]CentOS 使用 Samba 之 Postfix 移機紀錄 (冷日 (冷日), 2014/8/22 14:02)
|