Postfix
後綴根電子郵件僅作為密件抄送轉發到外部地址
我已經設置了 postfix 來通過我的 gmail 帳戶中繼 proxmox 消息,並使用別名將我所有的根電子郵件轉發到外部地址。使用 sendmail 命令時,可以在 gmail 的已發送文件夾中看到電子郵件,收件人:欄位為空,密件抄送:是我的外部地址。使用 mail -s 時,可以在 gmail 發送的文件夾中看到電子郵件,其中 To: 欄位作為原始根電子郵件,Bcc: 是我的外部地址。
我的轉發地址不應該在 To: 欄位中替換 root@pve.home.com 而不是 Bcc: 並完全停止發送到 root@pve.home.com 嗎?
根電子郵件的測試命令
# echo -e "Subject:Hello World \n\n Testing email\n" | sendmail root # echo "testing" | mail -s "test message" root
日誌文件
Dec 29 12:56:13 pve postfix/pickup[32080]: DB1E662DFA: uid=0 from=<root> Dec 29 12:56:13 pve postfix/cleanup[32097]: DB1E662DFA: message-id=<20171229175613.DB1E662DFA@pve.home.com> Dec 29 12:56:13 pve postfix/qmgr[32081]: DB1E662DFA: from=<root@pve.home.com>, size=390, nrcpt=1 (queue active) Dec 29 12:56:13 pve postfix/cleanup[32097]: E13A162DF8: message-id=<20171229175613.DB1E662DFA@pve.home.com> Dec 29 12:56:13 pve postfix/local[32099]: DB1E662DFA: to=<root@pve.home.com>, orig_to=<root>, relay=local, delay=0.04, delays=0.03/0.01/0/0, dsn=2.0.0, status=sent (forwarded as E13A162DF8) Dec 29 12:56:13 pve postfix/qmgr[32081]: E13A162DF8: from=<root@pve.home.com>, size=515, nrcpt=1 (queue active) Dec 29 12:56:13 pve postfix/qmgr[32081]: DB1E662DFA: removed Dec 29 12:56:13 pve postfix/smtp[32100]: connect to smtp.gmail.com[2607:f8b0:4001:c1d::6c]:587: Network is unreachable Dec 29 12:56:14 pve postfix/smtp[32100]: E13A162DF8: to=<someone@icloud.com>, orig_to=<root>, relay=smtp.gmail.com[74.125.126.109]:587, delay=0.85, delays=0/0.03/0.37/0.45, dsn=2.0.0, status=sent (250 2.0.0 OK 1514570174 f126sm11045770ioa.84 - gsmtp) Dec 29 12:56:14 pve postfix/qmgr[32081]: E13A162DF8: removed Dec 29 12:59:40 pve postfix/pickup[32080]: D6C9362DFA: uid=0 from=<root> Dec 29 12:59:40 pve postfix/cleanup[32429]: D6C9362DFA: message-id=<20171229175940.D6C9362DFA@pve.home.com> Dec 29 12:59:40 pve postfix/qmgr[32081]: D6C9362DFA: from=<root@pve.home.com>, size=280, nrcpt=1 (queue active) Dec 29 12:59:40 pve postfix/cleanup[32429]: DDD4D62DF8: message-id=<20171229175940.D6C9362DFA@pve.home.com> Dec 29 12:59:40 pve postfix/local[32431]: D6C9362DFA: to=<root@pve.home.com>, orig_to=<root>, relay=local, delay=0.05, delays=0.03/0.01/0/0.01, dsn=2.0.0, status=sent (forwarded as DDD4D62DF8) Dec 29 12:59:40 pve postfix/qmgr[32081]: DDD4D62DF8: from=<root@pve.home.com>, size=405, nrcpt=1 (queue active) Dec 29 12:59:40 pve postfix/qmgr[32081]: D6C9362DFA: removed Dec 29 12:59:41 pve postfix/smtp[32432]: connect to smtp.gmail.com[2607:f8b0:4001:c1d::6c]:587: Network is unreachable Dec 29 12:59:41 pve postfix/smtp[32432]: DDD4D62DF8: to=<someone@icloud.com>, orig_to=<root>, relay=smtp.gmail.com[74.125.126.109]:587, delay=0.93, delays=0.01/0.02/0.52/0.38, dsn=2.0.0, status=sent (250 2.0.0 OK 1514570381 a69sm13573861itc.18 - gsmtp) Dec 29 12:59:41 pve postfix/qmgr[32081]: DDD4D62DF8: removed
別名
root: someone@icloud.com postmaster: root nobody: root hostmaster: root webmaster: root www:root
main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version myhostname=pve.home.com smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = $myhostname, localhost.$mydomain, localhost #relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 inet_interfaces = loopback-only recipient_delimiter = + # sets gmail as relay relayhost = [smtp.gmail.com]:587 # use tls smtp_use_tls=yes # use sasl when authenticating to foreign SMTP servers smtp_sasl_auth_enable = yes # path to password map file smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd # list of CAs to trust when verifying server certificate smtp_tls_CAfile = /etc/ssl/certs/Equifax_Secure_CA.pem smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache smtp_tls_session_cache_timeout = 3600s # eliminates default security options which are imcompatible with gmail smtp_sasl_security_options =
主機
127.0.0.1 localhost.localdomain localhost 127.0.1.1 pve.home.com pve pvelocalhost # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts
郵件名
pve.home.com
預設情況下不會重寫地址;為此,Sendmail 功能是
genericstable
Postfix 呼叫的generic(5)
,因此理論上添加smtp_generic_maps = hash:/etc/postfix/generic
到您的
main.cf
然後添加條目,/etc/postfix/generic
例如root@pve.home.com someone@icloud.com
然後執行
postmap /etc/postfix/generic
並重新啟動 Postfix 應該會導致地址重寫。(這可能會因郵件傳輸代理(如 Postfix)使用的信封地址與郵件本身中存在的正文地址之間的區別而變得複雜……)在這種
| sendmail
情況下,您應該提供適當的To
地址標頭以及Subject
,或者使用郵件使用者代理(例如