发送和接收邮件、Dovecot、Postfix 等问题

发送和接收邮件、Dovecot、Postfix 等问题

我已经尝试修复我的邮件服务器 3 天了。我对 Debian 和 Apache 等并不陌生,但我对 Dovecot 和 Postfix 还不熟悉。

此时,我已经设置了虚拟用户和身份验证,一切正常。我通过 postfixadmin 进行管理。那里没有问题,我可以毫无问题地登录 roundcube 界面。我思考Dovecot 运行良好,因为它并没有在日志中给我带来错误。

Postfix 似乎并不关心我对它做了什么。它只是拒绝发送或接收任何邮件。如果我发送邮件,我会在日志中收到超时或无用的身份验证失败错误。如果我从 gmail 向自己发送电子邮件,我会收到

Mar 27 16:23:08 mail postfix/submission/smtpd[15969]: error: open database /etc/postfix/sender_access.db: No such file or directory
Mar 27 16:23:08 mail postfix/submission/smtpd[15969]: connect from mail-qg0-f47.google.com[209.85.192.47]
Mar 27 16:23:08 mail postfix/submission/smtpd[15969]: Anonymous TLS connection established from mail-qg0-f47.google.com[209.85.192.47]: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bit$
Mar 27 16:23:08 mail postfix/trivial-rewrite[15973]: warning: do not list domain mail.myserver.space in BOTH mydestination and virtual_mailbox_domains
Mar 27 16:23:08 mail postfix/submission/smtpd[15969]: NOQUEUE: reject: RCPT from mail-qg0-f47.google.com[209.85.192.47]: 554 5.7.1 <mail-qg0-f47.google.com[209.85.192.47]>: Client host rejected: A$
Mar 27 16:23:08 mail postfix/submission/smtpd[15969]: disconnect from mail-qg0-f47.google.com[209.85.192.47]

我注意到它说我的服务器名称被列出了 2 次。我多次搜索我的配置,它只列出了一次。我甚至注释掉了那个列表,但仍然收到错误。

这是我的 main.cf

debug_peer_list = localhost


# 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 = mail.mydomain.space
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
#mydestination = mail.mydomain.space, 127.0.0.1,  localhost.localdomain, localhost
#relayhost =
mynetworks = 127.0.0.0/8, [::ffff:127.0.0.0]/104, [::1]/128, mail.mydomain.space
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
mynetworks_style = subnet

# SASL parameters
# ---------------------------------

# Use Dovecot to authenticate.
smtpd_sasl_type = dovecot
# Referring to /var/spool/postfix/private/auth
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
#smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain =
smtpd_sasl_authenticated_header = yes


# TLS parameters
# ---------------------------------

# The default snakeoil certificate. Comment if using a purchased
# SSL certificate.
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

# Uncomment if using a purchased SSL certificate.
# smtpd_tls_cert_file=/etc/ssl/certs/example.com.crt
# smtpd_tls_key_file=/etc/ssl/private/example.com.key

# The snakeoil self-signed certificate has no need for a CA file. But
# if you are using your own SSL certificate, then you probably have
# a CA certificate bundle from your provider. The path to that goes
# here.
# smtpd_tls_CAfile=/etc/ssl/certs/ca-bundle.crt

# Ensure we're not using no-longer-secure protocols.
smtpd_tls_mandatory_protocols=!SSLv2,!SSLv3

smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
#smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# Note that forcing use of TLS is going to cause breakage - most mail servers
# don't offer it and so delivery will fail, both incoming and outgoing. This is
# unfortunate given what various governmental agencies are up to these days.
#
# Enable (but don't force) all incoming smtp connections to use TLS.
smtpd_tls_security_level = may
# Enable (but don't force) all outgoing smtp connections to use TLS.
smtp_tls_security_level = may

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


# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
# will it be a permanent error or temporary
unknown_local_recipient_reject_code = 450
# how long to keep message on queue before return as failed.
# some have 3 days, I have 16 days as I am backup server for some people
# whom go on holiday with their server switched off.
maximal_queue_lifetime = 7d
# max and min time in seconds between retries if connection failed
minimal_backoff_time = 1000s
maximal_backoff_time = 8000s
# how long to wait when servers connect before receiving rest of data
smtp_helo_timeout = 60s
# how many address can be used in one message.
# effective stopper to mass spammers, accidental copy in whole address list
# but may restrict intentional mail shots.
smtpd_recipient_limit = 16
# how many error before back off.
smtpd_soft_error_limit = 3
# how many max errors before blocking it.
smtpd_hard_error_limit = 12


# This next set are important for determining who can send mail and relay mail
# to other servers. It is very important to get this right - accidentally producing
# an open relay that allows unauthenticated sending of mail is a Very Bad Thing.
#
# You are encouraged to read up on what exactly each of these options accomplish.

# Requirements for the HELO statement
smtpd_helo_restrictions =   permit_mynetworks,
                            warn_if_reject reject_non_fqdn_hostname,
                            reject_invalid_hostname,
                            permit

# Requirements for the sender details
smtpd_sender_restrictions = permit_sasl_authenticated,
                            permit_mynetworks,
                            warn_if_reject reject_non_fqdn_sender,
                            reject_unknown_sender_domain,
                            reject_unauth_pipelining,
                            permit

smtpd_client_restrictions = reject_rbl_client sbl.spamhaus.org, 
                            reject_rbl_client blackholes.easynet.nl,
                            reject_rbl_client dnsbl.njabl.org

# Requirement for the recipient address. Note that the entry for
# "check_policy_service inet:127.0.0.1:10023" enables Postgrey.
smtpd_recipient_restrictions =  reject_unauth_pipelining,
                                permit_mynetworks,
                                permit_sasl_authenticated,
                                reject_non_fqdn_recipient,
                                reject_unknown_recipient_domain,
                                reject_unauth_destination,
                                check_policy_service inet:127.0.0.1:10023,
                                permit

# This is a new option as of Postfix 2.10, and is required in addition tocheck_sender_access
# smtpd_recipient_restrictions for things to work properly in this setup.

smtpd_relay_restrictions =  reject_unauth_pipelining,
                            permit_mynetworks,
                            permit_sasl_authenticated,
                            reject_non_fqdn_recipient,
                            reject_unknown_recipient_domain,
                            reject_unauth_destination,
                            permit
                            reject_rbl_client zen.spamhaus.org,
                            reject_rbl_client bl.spamcop.net,
                            check_policy_service unix:postgrey/socket,
                            permit

# require proper helo at connections
smtpd_helo_required = yes
#waste spammers time before rejecting them
smtpd_delay_reject = yes
disable_vrfy_command = yes


# General host and delivery info
# ----------------------------------

#myhostname = mail.mydomain.space
#myorigin = /etc/hostname
# Some people see issues when setting mydestination explicitly to the server
# subdomain, while leaving it empty generally doesn't hurt. So it is left empty here.
# mydestination = mail.example.com, localhost
#mydestination =
# If you have a separate web server that sends outgoing mail through this
# mailserver, you may want to add its IP address to the space-delimited list in
# mynetworks, e.g. as 10.10.10.10/32.
#mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
#mailbox_size_limit = 0
#recipient_delimiter = +
inet_interfaces = all
#mynetworks_style = host

# This specifies where the virtual mailbox folders will be located.
virtual_mailbox_base = /var/vmail
# This is for the mailbox location for each user. The domainaliases
# map allows us to make use of Postfix Admin's domain alias feature.
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf, mysql:/etc/postfix/mysql_virtual_mailbox_domainaliases_maps.cf
# and their user id
virtual_uid_maps = static:150
# and group id
virtual_gid_maps = static:8
# This is for aliases. The domainaliases map allows us to make
# use of Postfix Admin's domain alias feature.
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf, mysql:/etc/postfix/mysql_virtual_alias_domainaliases_maps.cf
# This is for domain lookups.
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf

抱歉,配置文件太乱了。部分原因是我必须从我的 Nexus 7 平板电脑上进行所有这些配置。

答案1

哇...这里有好多错误。我们来一一分析一下。

错误:打开数据库 /etc/postfix/sender_access.db:没有此文件或目录

看起来过去你已经设定好了/etc/postfix/sender_access并且main.cf忘记了跑步postmap /etc/postfix/sender_access

警告:请勿在 mydestination 和 virtual_mailbox_domains 中列出域 mail.myserver.space

我注意到它说我的服务器名称被列出了 2 次。我多次搜索我的配置,它只列出了一次。我甚至注释掉了那个列表,但仍然收到错误。

如果你注释掉该参数,那么该参数的值将变为默认值。`mydestination 的默认值是

mydestination = $myhostname, localhost.$mydomain, localhost

并且因为 myhostname = mail.mydomain.space,所以 postfix 仍然会警告上述消息。

永久解决方案,将 mydestionation 设置为

mydestination = localhost.$mydomain, localhost

NOQUEUE:拒绝:来自 mail-qg0-f47.google.com[209.85.192.47] 的 RCPT:554 5.7.1:客户端主机拒绝:A$

截断错误,因此我们看不到客户端被拒绝的原因。

相关内容