POSTFIX:邮件随机发送

POSTFIX:邮件随机发送

我正在尝试按照以下教程设置邮件服务器:https://www.linode.com/docs/email/postfix/email-with-postfix-dovecot-and-mysql#sph_dovecot

我之前已经使用本教程设置了邮件服务器,但在发送邮件时遇到了问题。我可以毫无问题地接收邮件。

如果我尝试使用 telnet 发送电子邮件telnet 92.243.20.113 25

我得到了以下登录信息/var/log/mail.log

Mar 11 17:07:15 server01 postfix/smtpd[10648]: dict_mysql: successful query from host 127.0.0.1
Mar 11 17:07:15 server01 postfix/smtpd[10648]: dict_mysql_lookup: retrieved 0 rows
Mar 11 17:07:15 server01 postfix/smtpd[10648]: maps_find: virtual_alias_maps: @hotmail.com: not found
Mar 11 17:07:15 server01 postfix/smtpd[10648]: mail_addr_find: [email protected] -> (not found)
Mar 11 17:07:15 server01 postfix/smtpd[10648]: before input_transp_cleanup: cleanup flags = enable_header_body_filter enable_automatic_bcc enable_address_mapping enable_milters
Mar 11 17:07:15 server01 postfix/smtpd[10648]: after input_transp_cleanup: cleanup flags = enable_header_body_filter enable_automatic_bcc enable_address_mapping
Mar 11 17:07:15 server01 postfix/smtpd[10648]: connect to subsystem public/cleanup
Mar 11 17:07:15 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: queue_id
Mar 11 17:07:15 server01 postfix/smtpd[10648]: input attribute name: queue_id
Mar 11 17:07:15 server01 postfix/smtpd[10648]: input attribute value: 8ACE3260AC
Mar 11 17:07:15 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: (list terminator)
Mar 11 17:07:15 server01 postfix/smtpd[10648]: input attribute name: (end)
Mar 11 17:07:15 server01 postfix/smtpd[10648]: send attr flags = 178
Mar 11 17:07:15 server01 postfix/smtpd[10648]: 8ACE3260AC: client=localhost[127.0.0.1]
Mar 11 17:07:15 server01 postfix/smtpd[10648]: > localhost[127.0.0.1]: 250 2.1.5 Ok
Mar 11 17:07:53 server01 postfix/smtpd[10648]: < localhost[127.0.0.1]: data
Mar 11 17:07:53 server01 postfix/smtpd[10648]: > localhost[127.0.0.1]: 354 End data with <CR><LF>.<CR><LF>
Mar 11 17:07:56 server01 postfix/cleanup[10655]: 8ACE3260AC: message-id=<[email protected]>
Mar 11 17:07:56 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: status
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute name: status
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute value: 0
Mar 11 17:07:56 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: reason
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute name: reason
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute value: (end)
Mar 11 17:07:56 server01 postfix/smtpd[10648]: public/cleanup socket: wanted attribute: (list terminator)
Mar 11 17:07:56 server01 postfix/smtpd[10648]: input attribute name: (end)
Mar 11 17:07:56 server01 postfix/smtpd[10648]: > localhost[127.0.0.1]: 250 2.0.0 Ok: queued as 8ACE3260AC
Mar 11 17:07:56 server01 postfix/qmgr[10559]: 8ACE3260AC: from=<[email protected]>, size=316, nrcpt=1 (queue active)
Mar 11 17:07:56 server01 postfix/smtp[10657]: 8ACE3260AC: to=<[email protected]>, relay=none, delay=55, delays=55/0.01/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=hotmail.com type=MX: Host not found, try again)
Mar 11 17:09:11 server01 postfix/smtpd[10648]: < localhost[127.0.0.1]: quit
Mar 11 17:09:11 server01 postfix/smtpd[10648]: > localhost[127.0.0.1]: 221 2.0.0 Bye
Mar 11 17:09:11 server01 postfix/smtpd[10648]: match_hostname: localhost ~? 127.0.0.0/8
Mar 11 17:09:11 server01 postfix/smtpd[10648]: match_hostaddr: 127.0.0.1 ~? 127.0.0.0/8
Mar 11 17:09:11 server01 postfix/smtpd[10648]: disconnect from localhost[127.0.0.1]
Mar 11 17:09:11 server01 postfix/smtpd[10648]: master_notify: status 1
Mar 11 17:09:11 server01 postfix/smtpd[10648]: connection closed
Mar 11 17:09:11 server01 postfix/smtpd[10648]: proxymap stream disconnect
Mar 11 17:09:11 server01 postfix/smtpd[10648]: auto_clnt_close: disconnect private/tlsmgr stream
Mar 11 17:09:11 server01 postfix/smtpd[10648]: rewrite stream disconnect
Mar 11 17:09:24 server01 postfix/qmgr[10559]: 7DABD2608F: from=<[email protected]>, size=342, nrcpt=1 (queue active)
Mar 11 17:09:24 server01 postfix/qmgr[10559]: 1B74C260A5: from=<[email protected]>, size=333, nrcpt=1 (queue active)
Mar 11 17:09:24 server01 postfix/smtp[10661]: 1B74C260A5: to=<[email protected]>, relay=none, delay=461, delays=461/0.01/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=blabla.org type=MX: Host not found, try again)
Mar 11 17:09:27 server01 postfix/smtp[10657]: 7DABD2608F: to=<[email protected]>, relay=spool.mail.gandi.net[217.70.184.6]:25, delay=4995, delays=4992/0/0.02/3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 78645142298)
Mar 11 17:09:27 server01 postfix/qmgr[10559]: 7DABD2608F: removed
Mar 11 17:10:51 server01 postfix/smtpd[10648]: idle timeout -- exiting

这是我的 POSTFIX main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
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/emalsys.eu.crt
smtpd_tls_key_file=/etc/ssl/private/emalsys.eu.key
smtpd_use_tls=yes
smtpd_tls_auth_only = yes

#Enabling SMTP for authenticated users, and handing off authentication to Dovecot
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination

#smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

myhostname = server01.emalsys.eu
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
#mydestination = server01.emalsys.eu, localhost.emalsys.eu, , localhost
mydestination = localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

#Handing off local delivery to Dovecot's LMTP, and telling it where to store mail
virtual_transport = lmtp:unix:private/dovecot-lmtp

#Virtual domains, users, and aliases
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf

我尝试接收电子邮件,它们正常到达并创建文件,并且/var/mail/vhosts/test.eu/address 不时发送一些邮件(似乎是随机的)。如果我使用 tel net 多次发送电子邮件,则很少有邮件发出!有人有想法吗?

编辑我的 DNS 区域文件:

@ 10800 IN A 92.243.20.113
servertest 10800 IN A 92.243.20.113
www 10800 IN CNAME emalsys.eu.
@ 10800 IN MX 10 emalsys.eu.
@ 10800 IN MX 10 servertest.emalsys.eu.
emalsys.eu 10800 IN MX 20 servertest.emalsys.eu.

编辑2:我的 /etc/resolv.conf

nameserver 2001:4b98:dc0:49::225 
nameserver 217.70.184.225 
nameserver 217.70.184.226 
options timeout:1 attempts:3 rotate

DIG 输出

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> hotmail.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5163
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 4, ADDITIONAL: 9

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

;; ANSWER SECTION:
hotmail.com.        1112    IN  A   157.56.172.28
hotmail.com.        1112    IN  A   65.55.77.28
hotmail.com.        1112    IN  A   65.55.85.12
hotmail.com.        1112    IN  A   157.55.152.112

;; AUTHORITY SECTION:
hotmail.com.        65271   IN  NS  ns4.msft.net.
hotmail.com.        65271   IN  NS  ns3.msft.net.
hotmail.com.        65271   IN  NS  ns1.msft.net.
hotmail.com.        65271   IN  NS  ns2.msft.net.

;; ADDITIONAL SECTION:
ns1.msft.net.       257 IN  A   208.84.0.53
ns1.msft.net.       257 IN  AAAA    2620:0:30::53
ns2.msft.net.       65271   IN  A   208.84.2.53
ns2.msft.net.       65271   IN  AAAA    2620:0:32::53
ns3.msft.net.       257 IN  A   193.221.113.53
ns3.msft.net.       257 IN  AAAA    2620:0:34::53
ns4.msft.net.       65271   IN  A   208.76.45.53
ns4.msft.net.       65271   IN  AAAA    2620:0:37::53

;; Query time: 1 msec
;; SERVER: 2001:4b98:dc0:49::225#53(2001:4b98:dc0:49::225)
;; WHEN: Thu Mar 12 18:01:49 CET 2015
;; MSG SIZE  rcvd: 360

root@servertest:/var/mail/vhosts/emalsys.eu/alert/new# nano /etc/resolv.conf
root@servertest:/var/mail/vhosts/emalsys.eu/alert/new# dig hotmail.com

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> hotmail.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27077
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 4, ADDITIONAL: 9

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

;; ANSWER SECTION:
hotmail.com.        878 IN  A   65.55.77.28
hotmail.com.        878 IN  A   65.55.85.12
hotmail.com.        878 IN  A   157.55.152.112
hotmail.com.        878 IN  A   157.56.172.28

;; AUTHORITY SECTION:
hotmail.com.        65037   IN  NS  ns3.msft.net.
hotmail.com.        65037   IN  NS  ns2.msft.net.
hotmail.com.        65037   IN  NS  ns1.msft.net.
hotmail.com.        65037   IN  NS  ns4.msft.net.

;; ADDITIONAL SECTION:
ns1.msft.net.       23  IN  A   208.84.0.53
ns1.msft.net.       23  IN  AAAA    2620:0:30::53
ns2.msft.net.       65037   IN  A   208.84.2.53
ns2.msft.net.       65037   IN  AAAA    2620:0:32::53
ns3.msft.net.       23  IN  A   193.221.113.53
ns3.msft.net.       23  IN  AAAA    2620:0:34::53
ns4.msft.net.       65037   IN  A   208.76.45.53
ns4.msft.net.       65037   IN  AAAA    2620:0:37::53

;; Query time: 0 msec
;; SERVER: 2001:4b98:dc0:49::225#53(2001:4b98:dc0:49::225)
;; WHEN: Thu Mar 12 18:05:43 CET 2015
;; MSG SIZE  rcvd: 360

我试过 yahoo 和 gmail,结果是一样的

编辑 iptables 规则:

Chain INPUT (policy ACCEPT 26169 packets, 3116K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 27746 packets, 5201K bytes)
 pkts bytes target     prot opt in     out     source               destination         
Chain INPUT (policy ACCEPT 209 packets, 1045K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 123 packets, 9955 bytes)
 pkts bytes target     prot opt in     out     source               destination

编辑 5:邮件发送成功

 Mar 12 16:41:51 localhost postfix/smtp[21764]: 603F624A1D: to=<[email protected]>, relay=spool.mail.gandi.net[217.70.184.6]:25, delay=25, delays=22/0/0.01/3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 75F9511648D)
Mar 12 16:41:51 localhost postfix/qmgr[21542]: 603F624A1D: removed

编辑 6 尝试使用 postfix 用户进行挖掘

admin@servertest:~$ sudo -u postfix dig mx hotmail.com
sudo: unable to resolve host servertest
[sudo] password for admin: 

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> mx hotmail.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22487
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 4, ADDITIONAL: 73

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

;; ANSWER SECTION:
hotmail.com.        2771    IN  MX  5 mx3.hotmail.com.
hotmail.com.        2771    IN  MX  5 mx4.hotmail.com.
hotmail.com.        2771    IN  MX  5 mx1.hotmail.com.
hotmail.com.        2771    IN  MX  5 mx2.hotmail.com.

;; AUTHORITY SECTION:
hotmail.com.        63891   IN  NS  ns1.msft.net.
hotmail.com.        63891   IN  NS  ns4.msft.net.
hotmail.com.        63891   IN  NS  ns3.msft.net.
hotmail.com.        63891   IN  NS  ns2.msft.net.

;; ADDITIONAL SECTION:
mx1.hotmail.com.    2731    IN  A   65.55.92.168
mx1.hotmail.com.    2731    IN  A   65.55.92.184
mx1.hotmail.com.    2731    IN  A   207.46.8.167
[..] I removed lines to make the edit lighter
mx4.hotmail.com.    2737    IN  A   65.54.188.126
mx4.hotmail.com.    2737    IN  A   65.55.33.119
mx4.hotmail.com.    2737    IN  A   65.55.33.135
mx4.hotmail.com.    2737    IN  A   65.55.37.72
mx4.hotmail.com.    2737    IN  A   65.55.37.88
mx4.hotmail.com.    2737    IN  A   65.55.37.104
mx4.hotmail.com.    2737    IN  A   65.55.37.120
ns1.msft.net.       81  IN  A   208.84.0.53
ns1.msft.net.       81  IN  AAAA    2620:0:30::53
ns2.msft.net.       63891   IN  A   208.84.2.53
ns2.msft.net.       63891   IN  AAAA    2620:0:32::53
ns3.msft.net.       81  IN  A   193.221.113.53
ns3.msft.net.       81  IN  AAAA    2620:0:34::53
ns4.msft.net.       63891   IN  A   208.76.45.53
ns4.msft.net.       63891   IN  AAAA    2620:0:37::53

;; Query time: 2 msec
;; SERVER: 2001:4b98:dc0:49::225#53(2001:4b98:dc0:49::225)
;; WHEN: Thu Mar 12 18:24:49 CET 2015
;; MSG SIZE  rcvd: 1400

答案1

Host or domain name not found. Name service error for name=hotmail.com

Host or domain name not found. Name service error for name=blabla.org

在我看来,这很像是您的 DNS 无法正常工作 - 具体来说,您的邮件服务器上的名称解析无法正常工作。您需要一个在 中列出的正常工作的名称服务器/etc/resolv.conf,并且您的防火墙中不需要阻止 DNS 查询,以便传递出站邮件。

编辑iptables您上面引用的规则不仅单独来看毫无用处(请参阅下面的评论,了解我们现在需要什么信息),而且这些INPUT规则完全是错误的;它们需要说--sport 53,而不是--dport 53,才能允许 DNS 响应。目前,我非常怀疑您正在阻止自己的 DNS 查找 - 但直到我们看到我所请求的iptablesip6tables输出,我们才会知道。

答案2

/etc/resolv.conf和 的权限是什么/etc/nsswitch.conf?它们应该可以被所有用户读取(postfix 不是以 root 身份运行)。

通过快速网络搜索“postfix resolv.conf 权限”,我们发现,如果其中一个或两个权限只有 root 可读,则会导致出现此行为。

尽管这些文件的权限没有问题(请参阅下面 raphael_b 的评论)我仍然怀疑这可能是问题的根源,因为 DNS 查找在命令行上是正常的(我假设它是以 root 身份运行)但似乎从内部失败了postfix

您可以尝试digpostfix用户身份运行吗?

sudo -u postfix dig mx hotmail.com

如果可行,那么至少我们已经消除了文件权限问题(如果不行,我们有一个更简单的问题需要解决)。

相关内容