Email

Postfix 不需要對本地電子郵件進行身份驗證?

  • October 15, 2019

根據本教程,我有一個 Postfix/Courier 郵件伺服器(通過 SASL/MySQL 驗證)。我目前在 Debian 6 上執行我的伺服器,它是一個 VPS。據我所見,它執行良好,但我似乎不需要對入站電子郵件發送進行身份驗證。如果我從 Outlook 向我自己發送一封禁用 SMTP 身份驗證的電子郵件,一切都會發生並且我沒有被拒絕,伺服器上的日誌會告訴我:

Dec 19 09:39:33 new postfix/smtpd[20439]: connect from unknown[****]
Dec 19 09:39:33 new postfix/smtpd[20439]: 7FF1E469840: client=unknown[****]
Dec 19 09:39:33 new postfix/cleanup[20444]: 7FF1E469840: message-id=<000c01cefc31$41319a90$c394cfb0$@email@mydomain>
Dec 19 09:39:33 new postfix/qmgr[20429]: 7FF1E469840: from=<email@mydomain>, size=2730, nrcpt=1 (queue active)
Dec 19 09:39:33 new postfix/virtual[20445]: 7FF1E469840: to=<email@mydomain>, relay=virtual, delay=0.49, delays=0.4/0.08/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)
Dec 19 09:39:33 new postfix/qmgr[20429]: 7FF1E469840: removed
Dec 19 09:39:36 new postfix/smtpd[20439]: disconnect from unknown[****]

****表示郵件客戶端的IP地址

但是,如果我嘗試向外部域(例如 gmail 地址)發送電子郵件,則電子郵件如預期的那樣被拒絕並退回:

Your message did not reach some or all of the intended recipients.

 Subject:  
 Sent: 19/12/2013 9:49 a.m.

The following recipient(s) cannot be reached:

 'email@external.domain' on 19/12/2013 9:49 a.m.
       Server error: '554 5.7.1 <email@external.domain>: Relay access denied'

該日誌還吐出了一些關於拒絕身份驗證的內容(這是意料之中的)

Dec 19 09:48:34 new postfix/smtpd[20449]: connect from unknown[****]
Dec 19 09:48:34 new postfix/smtpd[20449]: NOQUEUE: reject: RCPT from unknown[****]: 554 5.7.1 <email@external.domain>: Relay access denied; from=<email@mydomain> to=<email@external.domain> proto=ESMTP helo=<MyPC>
Dec 19 09:48:36 new postfix/smtpd[20449]: disconnect from unknown[****]

如果我在我的電子郵件客戶端 (Outlook) 上啟用 SMTP 身份驗證,一切都會按預期工作。實際上是否正在進行一些我沒有看到的身份驗證,或者這是否充當內部電子郵件的開放中繼?如果是這種情況,如何強制對所有電子郵件進行身份驗證?

我的 main.cf 是:

relayhost = 
mynetworks = 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_protocols = all
broken_sasl_auth_clients = yes
virtual_alias_domains = 
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /home/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
virtual_create_maildirsize = yes
virtual_maildir_extended = yes
virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = "The user you are trying to reach is over quota."
virtual_overquota_bounce = yes
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps

您的伺服器不是開放中繼。它被設置為允許三種不同類型的郵件:

  1. 來自網際網路上任何人的郵件您自己域內的地址
  2. 源自您自己的郵件伺服器的郵件(例如來自 cron 作業等的通知),發給 Internet 上的任何人
  3. 來自網際網路上任何人的經過身份驗證的連接的郵件

如果郵件不符合上述任何一項,那麼郵件伺服器將拒絕它,即使垃圾郵件發送者在您的域中放置了一些虛假地址作為發件人地址。

引用自:https://serverfault.com/questions/562297