Postfix + Dovecot + saslauthd无法接收来自外部的电子邮件

在我的Linode上,我按照这个文档来设置邮件服务器。

现在我可以发送电子邮件到任何域名,但不能从其他域接收!
我的意思是[email protected]可以从[email protected]收到邮件,但不能收到xxx @ gmail / yahoo / … com的任何邮件。 我也检查了我的vmail(Maildir),其他域的邮件不在那里。

我收到来自gmail的邮件状态通知(延迟) (约24小时后):

Delivery to the following recipient has been delayed: [email protected] Message will be retried for 2 more day(s) Technical details of temporary failure: The recipient server did not accept our requests to connect. Learn more at http://mail.google.com/support/bin/answer.py?answer=7720 [mail.mydomain.com. (10): Connection refused] 

这是我的设置:
我有一个MXlogging:

 mail.mydomain.com 

A / AAAAlogging

 mail (with same ip as my server) 

我的/ etc / hosts

 127.0.0.1 localhost.localdomain localhost (server ip) hostname.mydomain.com hostname 

我的/ etc / default / saslauthd

 START=yes DESC="SASL Authentication Daemon" NAME="saslauthd" MECHANISMS="pam" MECH_OPTIONS="" THREADS=5 OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r" 

我的/ etc /别名

 postmaster: root root: [email protected] 

我的/usr/share/postfix/main.cf

 protocols = imap imaps pop3 pop3s log_timestamp = "%Y-%m-%d %H:%M:%S " mail_location = maildir:/home/vmail/%d/%n/Maildir ssl_cert_file = /etc/ssl/certs/dovecot.pem ssl_key_file = /etc/ssl/private/dovecot.pem namespace private { separator = . prefix = INBOX. inbox = yes } protocol lda { log_path = /home/vmail/dovecot-deliver.log auth_socket_path = /var/run/dovecot/auth-master postmaster_address = [email protected] mail_plugins = sieve global_script_path = /home/vmail/globalsieverc } protocol pop3 { pop3_uidl_format = %08Xu%08Xv } auth default { user = root passdb sql { args = /etc/dovecot/dovecot-sql.conf } userdb static { args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes } socket listen { master { path = /var/run/dovecot/auth-master mode = 0600 user = vmail } client { path = /var/spool/postfix/private/auth mode = 0660 user = postfix group = postfix } } 

我的/usr/share/postfix/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 (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 = /usr/share/doc/postfix # TLS parameters smtpd_tls_cert_file = /etc/postfix/smtpd.cert smtpd_tls_key_file = /etc/postfix/smtpd.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 = hostname.mydomain.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = hostname.mydomain.com, localhost, localhost.localdomain relayhost = mynetworks = 127.0.0.0/8 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = (server ip), 127.0.0.1 html_directory = /usr/share/doc/postfix/html message_size_limit = 30720000 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 broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destinationvirtual_create_maildirsize = yes virtual_maildir_extended = 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 virtual_transport = dovecot dovecot_destination_recipient_limit = 1 

我的iptables规则:
(我使用2525而不是25端口,它在我的机器和isp打开,我可以远程login)

  pkts bytes target prot opt in out source destination 130 7820 ACCEPT tcp -- any any anywhere anywhere tcp dpt:smtp 0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:25 388 33099 ACCEPT tcp -- any any anywhere anywhere tcp dpt:2525 0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:2525 0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:100 0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:pop3 65 3538 ACCEPT tcp -- any any anywhere anywhere tcp dpt:pop3 0 0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:26 0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:26 0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:pop3s 2355 184K ACCEPT tcp -- any any anywhere anywhere tcp dpt:pop3s 

日志
当我收到其他域邮件时,没有任何东西添加到我的/ var / log / mail.log中 ,但是当我尝试通过邮件客户端收到邮件时, 似乎没有问题

 Apr 14 07:53:51 hostname dovecot: pop3-login: Login: user=<[email protected]>, method=PLAIN, rip=94.182.127.182, lip=178.79.152.29, TLS Apr 14 07:53:52 hostname dovecot: POP3([email protected]): Disconnected: Logged out top=0/0, retr=0/0, del=0/7, size=6546 

/ home / vmail / dovecot-deliver.log没有任何反应,当我从其他域收到邮件,但在相同的域名电子邮件似乎正常:

 2011-04-14 05:42:53 deliver([email protected]): Info: msgid=<[email protected]>: saved mail to INBOX 

我通过VMail,Mutt,Apple Mail和Thunderbird检查邮件,这是我在邮件客户端上的设置:
帐户types: pop3
传入邮件服务器: mail.mydomain.com
用户名: [email protected]
密码: XXXXX
对外邮件服务器:
服务器名称: mail.mydomain.com
港口: 2525
使用SSL
自动分配:密码
用户名: [email protected]
密码: XXXXX

由于在/var/mail/mail.log中绝对没有logging任何东西,并且你的链接显示零stream量进入tcp / 25,我相信你的ISP阻止在tcp / 25上的传入stream量。 这对于家庭用户来说是正常的做法。 除非你有一个商务舱的连接,否则ISP不允许他们的用户stream量指定为tcp / 25。

你需要一些类似DynDNS'mailhop的外部服务。 您将DynDNS设置为您的MX,并将其邮件转发到您的服务器上打开的目标端口,如2525。

编辑: 要清楚 ; 真正的互联网电子邮件只能通过端口tcp / 25。 你不能像2525那样打开一个端口,并期望它工作。

由于我的ISP也阻塞端口25,我添加了另一个端口(2525)到/etc/postfix/main.cf。 但是,我犯了一个错误,将smtp端口注释掉,导致从外部接收邮件失败。

 # Does not work #smtp inet n - - - - smtpd 2525 inet n - - - - smtpd 

要接收来自其他服务器的邮件,并绕过ISP的端口限制,只需打开端口25(smtp)和另一个端口即可。

 # Works smtp inet n - - - - smtpd 2525 inet n - - - - smtpd