我已经设置了从 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(不带域名)。随后我将它们改回 redmine.hsi.com 并运行:
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 的名称服务错误,类型=AAAA:找到主机,但没有请求类型的数据记录
首先,Postfix 将查找 MX 记录,如果失败,它将通过查找 A 记录(IPv4)和 AAAA 记录(IPv6)来回退。由于 Postfix 无法从上述三个记录中找到您域的目标主机,因此 Postfix 会退回您的电子邮件。
答案2
尝试将 myhostname 更改为其他名称 - 例如 mail.redmine.hsi.com