把家庭辦公環境的postfix應用技巧和提示整合到這篇文檔的目的是便於查找。這篇文檔僅描述了郵件的發送。如果你的postfix服務器不直接接收郵件(比如:它沒有公網的域名和固定的IP),那麼你將需要一個類似於“fetchmail”的解決方法--這超出了postfix的文檔範圍
·基於internet主機的postfix安裝
·基於Intranet主機的postfix安裝
從SASL_README文檔中選擇相關主題:
·在postfix的smtp客戶端啓用SASL認證
·配置郵件發送者的SASL認證
關於這些主題的更詳細的信息查看SASL_README 和 STANDARD_CONFIGURATION_README文檔
postfix幾乎在沒有改變獨立主機的設置的前提下就能被安裝好。至少,當你下載postfix源碼後知道如何安裝postfix。
/etc/postfix/main.cf
myhostname=ceshi.linux.com (其中ceshi.linux.com是機器的FQDN)
mydomain=linux.com
myorigin=$mydomain
mydestination=$myhostname localhost.$mydomain localhost
mail.$mydomain
inet_interfaces=all
mynetworks=127.0.0.1/8 192.168.1.0/24
proxy_interfaces=1.2.3.4
relayhost = [mail.$mydomain]
/etc/aliases:
postmaster: [email protected]
root: [email protected]
這部分是適用於那些沒有internet主機名(即公網固定IP)的postfix主機。一般是那些通過DHCP或者撥號獲取公網動態IP地址的主機。postfix可以用一個不存在(fantasy)的名稱爲linux系統用戶提供發送/接收郵件的功能。但是當你在給internet用戶發郵件時,不能在郵件地址中使用這個名稱,因爲internet用戶將無法給你回覆郵件。實際上,越來越多的站點將拒絕域名不存在的郵件。
postfix 2.2 使用通用的地址映射方法把本地郵件地址映射爲internet上的有效地址。這個映射僅在郵件發送出postfix主機時才發生;當郵件在同一臺機器的不同用戶間傳遞郵件時,將不會使用地址映射功能。
2 smtp_generic_maps = hash:/etc/postfix/generic
3
4 /etc/postfix/generic:
5 [email protected] [email protected]
6 [email protected] [email protected]
7 @localdomain.local [email protected]
第5,6行 左邊是內部的郵件地址,右邊的部分是公網的郵件地址
老版本的postfix系統是使用有效地internet地址,並且讓postfix把有效的internet地址映射爲本地的地址。這樣,你能發送郵件給internet用戶和本地用戶。
2 myhostname = hostname.localdomain
3 mydomain = localdomain
4
5 canonical_maps = hash:/etc/postfix/canonical
6
7 virtual_alias_maps = hash:/etc/postfix/virtual
8
9 /etc/postfix/canonical:
10 your-login-name [email protected]
11
12 /etc/postfix/virtual:
13 [email protected] your-login-name
這個部分向你展示了一個典型的方案:postfix的smtp客戶端經過郵件網關sasl驗證後發送郵件。
如果你的sasl登陸失敗,並在maillog日誌文件裏提示:sasl驗證失敗:沒發現可用的驗證機制。這個錯誤參見“postfix SMTP/LMTP客戶端策略--SASL機制屬性”。
smtp_sasl_auth_enable = yes
relayhost = [mail.isp.example]
# Alternative form:
# relayhost = [mail.isp.example]:submission
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_auth_enable設置決定是否啓用客戶端的驗證。我們將在第二部分配置客戶端的用戶名和密碼信息。
# destination credentials
[mail.isp.example] username:password
# Alternative form:
# [mail.isp.example]:submission username:password
把sasl客戶端的密碼文件放在/etc/postfix目錄中,確保只有root用戶對該文件可讀寫。postfix的smtp客戶端可以讀取sasl客戶端的密碼。它在降低特權和使用chroot前,以root用戶的身份打開該文件
postfix爲不同的發送地址提供不同的isp帳戶(postfix 2.3版本之後)。當一個人使用同一臺機器用於工作和生活時,或者當同一臺postfix服務器使用不同的isp帳戶時,這個設置將非常有用。
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
relayhost = [mail.isp.example]
# Alternative form:
# relayhost = [mail.isp.example]:submission
/etc/postfix/sasl_passwd:
# Per-sender authentication; see also /etc/postfix/sender_relay.
[email protected] username2:password2
[email protected] username2:password2
# Login information for the default relayhost.
[mail.isp.example] username:password
# Alternative form:
# [mail.isp.example]:submission username:password
/etc/postfix/sender_relay:
# Per-sender provider; see also /etc/postfix/sasl_passwd.
[email protected] [mail.example.com]:submission
[email protected] [mail.example.net]