postfix 郵件(有效)到 debian 上除我的網域之外的所有網域

postfix 郵件(有效)到 debian 上除我的網域之外的所有網域

我已經設定了一個從turnkey linux 取得的redmine 伺服器。郵件或多或少是開箱即用的。我可以向不在我的網域中的任何人發送郵件。

讓我解釋:
如果我從命令列運行郵件命令並將其發送到我的個人電子郵件(或任何其他非網域電子郵件),它就會起作用。如果我向我網域中的任何人發送郵件,則不會。我們的郵件由 Google 處理並可尋找。由於某種原因,這台機器看到該網域並嘗試自行處理它(我不想要)。我只希望郵件能夠按照自然路徑到達 Google(或任何目的地)。我有一種感覺,如果我將機器的網域更改為我以外的網域(這對我來說沒問題),它將開始正常工作。我嘗試過這樣做,但我認為我錯過了一個。非常感激任何的幫助!

我想也許改變網域可能會欺騙 postfix。我更改了主機名稱檔案:

redmine.hsi.com

這是 main.cf 檔案:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

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

readme_directory = no

# TLS parameters
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = redmine
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localdomain, localhost, localhost.localdomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = localhost
smtpd_recipient_restrictions = permit_mynetworks reject_unauth_destination
smtp_sasl_password_maps = hash:/etc/postfix/smtp_sasl_password_map

這是master.cf:

#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
#smtp      inet  n       -       -       -       1       postscreen
#smtpd     pass  -       -       -       -       -       smtpd
#dnsblog   unix  -       -       -       -       0       dnsblog
#tlsproxy  unix  -       -       -       -       0       tlsproxy
#submission inet n       -       -       -       -       smtpd
#  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       -       -       -       smtpd
#  -o syslog_name=postfix/smtps
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       -       -       -       qmqpd
pickup    fifo  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
#   lmtp    cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
#  mailbox_transport = lmtp:inet:localhost
#  virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

這是mail.log

Feb 27 21:13:13 redmine postfix/pickup[15860]: 56D53C0D32: uid=0 from=<[email protected]>
Feb 27 21:13:13 redmine postfix/cleanup[19150]: 56D53C0D32: message-id=<20150227211313.56D53C0D32@redmine>
Feb 27 21:13:13 redmine postfix/qmgr[15861]: 56D53C0D32: from=<[email protected]>, size=349, nrcpt=1 (queue active)
Feb 27 21:13:13 redmine postfix/smtp[19159]: 56D53C0D32: to=<[email protected]>, relay=none, delay=0.06, delays=0.05/0.01/0/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=humansolutionsinc.com type=AAAA: Host found but no data record of requested type)
Feb 27 21:13:13 redmine postfix/cleanup[19150]: 5E24FC0D33: message-id=<20150227211313.5E24FC0D33@redmine>
Feb 27 21:13:13 redmine postfix/qmgr[15861]: 5E24FC0D33: from=<>, size=2276, nrcpt=1 (queue active)
Feb 27 21:13:13 redmine postfix/bounce[19166]: 56D53C0D32: sender non-delivery notification: 5E24FC0D33
Feb 27 21:13:13 redmine postfix/qmgr[15861]: 56D53C0D32: removed
Feb 27 21:13:13 redmine postfix/smtp[19159]: 5E24FC0D33: to=<[email protected]>, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=redmine.hsi.com type=AAAA: Host not found)
Feb 27 21:13:13 redmine postfix/qmgr[15861]: 5E24FC0D33: removed

這是mail.info:

Feb 27 21:13:13 redmine postfix/pickup[15860]: 56D53C0D32: uid=0 from=<[email protected]>
Feb 27 21:13:13 redmine postfix/cleanup[19150]: 56D53C0D32: message-id=<20150227211313.56D53C0D32@redmine>
Feb 27 21:13:13 redmine postfix/qmgr[15861]: 56D53C0D32: from=<[email protected]>, size=349, nrcpt=1 (queue active)
Feb 27 21:13:13 redmine postfix/smtp[19159]: 56D53C0D32: to=<[email protected]>, relay=none, delay=0.06, delays=0.05/0.01/0/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=humansolutionsinc.com type=AAAA: Host found but no data record of requested type)
Feb 27 21:13:13 redmine postfix/cleanup[19150]: 5E24FC0D33: message-id=<20150227211313.5E24FC0D33@redmine>
Feb 27 21:13:13 redmine postfix/qmgr[15861]: 5E24FC0D33: from=<>, size=2276, nrcpt=1 (queue active)
Feb 27 21:13:13 redmine postfix/bounce[19166]: 56D53C0D32: sender non-delivery notification: 5E24FC0D33
Feb 27 21:13:13 redmine postfix/qmgr[15861]: 56D53C0D32: removed
Feb 27 21:13:13 redmine postfix/smtp[19159]: 5E24FC0D33: to=<[email protected]>, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=redmine.hsi.com type=AAAA: Host not found)
Feb 27 21:13:13 redmine postfix/qmgr[15861]: 5E24FC0D33: removed

正如Tutul 所建議的,我將以下行添加到main.cf 中,重新啟動postfix,並再次嘗試發送電子郵件,結果相同:發送到humansolutionsinc.com 之外的任何網域的電子郵件都可以找到,發送給該網域內任何人的電子郵件則不會。

inet_protocols=ipv4

以下是 dig humansolutionsinc.com 的輸出:

root@redmine ~# dig humansolutionsinc.com

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> humansolutionsinc.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31920
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;humansolutionsinc.com.         IN      A

;; AUTHORITY SECTION:
humansolutionsinc.com.  3600    IN      SOA     hsiwd1.hsi.com. hostmaster.hsi.com. 5 900 600 86400 3600

;; Query time: 1 msec
;; SERVER: 192.168.1.4#53(192.168.1.4)
;; WHEN: Mon Mar  2 14:03:05 2015
;; MSG SIZE  rcvd: 97

以及 dig humansolutionsinc.com mx 的輸出:

root@redmine ~# dig humansolutionsinc.com mx

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> humansolutionsinc.com mx
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36172
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;humansolutionsinc.com.         IN      MX

;; AUTHORITY SECTION:
humansolutionsinc.com.  3600    IN      SOA     hsiwd1.hsi.com. hostmaster.hsi.com. 5 900 600 86400 3600

;; Query time: 1 msec
;; SERVER: 192.168.1.4#53(192.168.1.4)
;; WHEN: Mon Mar  2 14:03:13 2015
;; MSG SIZE  rcvd: 97

偉大的!一系列重新啟動後(解決其他問題 - 與郵件無關)郵件正在發送中

好的,回到第一點。我已將 /etc/host 和 /etc/hots 更改為 redmine (沒有網域)。

invoke-rc.d hostname.sh start
invoke-rc.d networking force-reload 

答案1

修復您的 NS 伺服器 192.168.1.4。它應該會傳回正確的 MX 和 A 記錄,而不是像上面那樣傳回空答案。

解釋:

這些日誌行

Feb 27 21:13:13 redmine postfix/pickup[15860]: 56D53C0D32: uid=0 from=<[email protected]>
Feb 27 21:13:13 redmine postfix/cleanup[19150]: 56D53C0D32: message-id=<20150227211313.56D53C0D32@redmine>
Feb 27 21:13:13 redmine postfix/qmgr[15861]: 56D53C0D32: from=<[email protected]>, size=349, nrcpt=1 (queue active)
Feb 27 21:13:13 redmine postfix/smtp[19159]: 56D53C0D32: to=<[email protected]>, relay=none, delay=0.06, delays=0.05/0.01/0/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=humansolutionsinc.com type=AAAA: Host found but no data record of requested type) 

告訴我們一封由mail寄件者命令調用的電子郵件[電子郵件受保護]和收件者[電子郵件受保護]

因為域humansolutionsinc.com如果沒有在mydestination參數中定義,則 postfix 會將此網域標記為傳出網域,因此 postfix 必須透過遠端 SMTP 傳送它。確定郵件伺服器負責的位置humansolutionsinc.com,postfix 使用 DNS 查找,特別是搜尋 MX 記錄(以及可選的 A 記錄)。我們可以使用指令dig來模擬NS查找。

這是我的伺服器的(正確的)挖掘輸出

$ dig humansolutionsinc.com

; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1 <<>> humansolutionsinc.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12591
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;humansolutionsinc.com.         IN      A

;; ANSWER SECTION:
humansolutionsinc.com.  1199    IN      A       98.136.187.13

;; Query time: 1508 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Mon Mar 02 19:21:03 WIB 2015
;; MSG SIZE  rcvd: 66

$ dig humansolutionsinc.com MX

; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1 <<>> humansolutionsinc.com MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35479
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;humansolutionsinc.com.         IN      MX

;; ANSWER SECTION:
humansolutionsinc.com.  599     IN      MX      10 aspmx.l.google.com.
humansolutionsinc.com.  599     IN      MX      20 alt1.aspmx.l.google.com.
humansolutionsinc.com.  599     IN      MX      20 alt2.aspmx.l.google.com.
humansolutionsinc.com.  599     IN      MX      30 aspmx2.googlemail.com.
humansolutionsinc.com.  599     IN      MX      30 aspmx3.googlemail.com.

;; Query time: 942 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Mon Mar 02 19:21:08 WIB 2015
;; MSG SIZE  rcvd: 180

與我的版本相比,您的挖掘輸出包含零答案

這解釋了為什麼 postfix 會抱怨像這樣的通用訊息

找不到主機或網域。 name= humansolutionsinc.com type= AAAA 的名稱服務錯誤:找到主機,但沒有請求類型的資料記錄

首先,Postfix 將尋找 MX 記錄,如果失敗,它將透過尋找 A 記錄(IPv4)然後尋找 AAAA 記錄(IPv6)進行回退。由於postfix無法從上述三個記錄中找到您網域的目標主機,因此postfix退回了您的電子郵件。

答案2

嘗試將 myhostname 變更為其他名稱 - 例如 mail.redmine.hsi.com

相關內容