2015年12月29日 星期二

在 Sendmail 中覆寫 E-mail address


使用 Sendmail 作為郵件伺服器, 我們可以覆寫所有郵件中的特定 E-mail address.

編輯 /etc/mail/genericstable

加入對應 email

youraccount  [email protected]

產生 Hash 檔

makemap -r hash genericstable.db < genericstable



另外也可以更改 /etc/mail/aliases , 不過此方式僅限於伺服器本地信件

加入對應名稱, 可以指向特定帳號或是裝置

youraccount   youaliasaccount

youraccount   /dev/yourdevice

執行 newaliases 更新檔案並生效

Postfix 關閉 IPv6


如果 Mail 伺服器有開啟 IPv6, 但沒有設定 PTR 的話, Gmail 會出現以下訊息予以退信

message does not meet IPv6 sending guidelines regarding PTR records 550-5.7.1

更新 PTR 可以解決此問題,  不過我們也可以藉由關閉 IPv6 來達成


開啟 Main.cf

首先更改 inet_protocols = all ,  改成  inet_protocols = ipv4



只改了 ipv4, 重啟 postfix 會出現錯誤訊息 "config variable inet_interfaces: host not found: [::1]"

接著把 inet_interfaces 更新

inet_interfaces = 127.0.0.1, [::1]   改成 inet_interfaces = 127.0.0.1

重新啟動 Postfix 之後即可




Postfix 郵件系統覆寫寄件者

php 安裝在 Linux 系統上的 Apache 時, 可以用內建 Postfix 郵件系統寄信,

不過寄件者會被覆寫成 apache 或是 www-data.

首先檢查 php.ini 的設定

[mail function]
; For Win32 only.
SMTP = localhost

; For Win32 only.
;sendmail_from = ***@yourdomain.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =\r

接著調整 postfix main.cf 的設定內容

加上
smtp_generic_maps = hash:/etc/postfix/generic

內容
[email protected]   [email protected]

接著執行
postmap /etc/postfix/generic

重新啟動 postfix
/etc/init.d/postfix restart

完成後信件就能以 [email protected] 寄出




PS. 在一些早期版本的 Postfix 需要設定的檔案不同

改為加上
sender_canonical_maps = hash:/etc/postfix/canonical

內容
[email protected]   [email protected]

接著執行
postmap /etc/postfix/generic

重新啟動 postfix
/etc/init.d/postfix restart