我已经搜索了几天甚至几周。好吧,我尝试配置 Postfix(失败了),目的是在不使用外部中继服务(如 Gmail)的情况下发送邮件,并配置一个(本地?)中继服务器,该服务器将通过端口 587 使用。
如果我错了,请纠正我,这个项目是我第一次熟悉电子邮件类型服务器的项目。
在解释之前,此环境将配置为生产类型的服务器。配置最终也将在 Docker 映像中进行,但我尝试通过在多个虚拟机上构建所有内容来学习每一步(此虚拟机在 HyperV 中)
我跟着这在过去的几天里,我按照教程成功完成了设置。接下来,我创建了一个客户端、一个(网站)和一个带邮箱的电子邮件域。这使得我可以成功登录 Roundcube。问题在于,当我尝试从 Roundcube 发送电子邮件时,我检查了日志文件,尝试重新配置 Postfix 部分(main.cf、master.cf 和 dpkg-reconfigure postfix,service postfix restart
当然,之后是)
以下是我的设置示例:
- 我在域 DNS 中设置了一个 MX 记录,其值为“subdomain.domain.ext”
- 我遵循与教程相同的主机名和/或 /etc/hosts 步骤:
以下示例根据上述 MX 值:
hostname (according to example) subdomain
cat /etc/hosts:
127.0.0.1 localhost.localdomain localhost
local_ip subdomain.domain.ext subdomain
The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Postfix main.cf:
# 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 = /usr/share/doc/postfix
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2
# 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.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = subdomain.domain.ext
alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases
alias_database = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases
myorigin = /etc/mailname
#mydestination = subdomain.domain.ext, localhost, localhost.localdomain
mydestination = localhost, localhost.localdomain
relayhost =
mynetworks = 127.0.0.0/8 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
html_directory = /usr/share/doc/postfix/html
virtual_alias_domains =
virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman, proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, proxy: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 = /var/vmail
virtual_uid_maps = mysql:/etc/postfix/mysql-virtual_uids.cf
virtual_gid_maps = mysql:/etc/postfix/mysql-virtual_gids.cf
sender_bcc_maps = proxy:mysql:/etc/postfix/mysql-virtual_outgoing_bcc.cf
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
smtpd_restriction_classes = greylisting
greylisting = check_policy_service inet:127.0.0.1:10023
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client zen.spamhaus.org, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, check_recipient_access mysql:/etc/postfix/mysql-virtual_policy_greylist.cf
smtpd_tls_security_level = may
transport_maps = hash:/var/lib/mailman/data/transport-mailman, proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
relay_domains = mysql:/etc/postfix/mysql-virtual_relaydomains.cf
relay_recipient_maps = mysql:/etc/postfix/mysql-virtual_relayrecipientmaps.cf
smtpd_sender_login_maps = proxy:mysql:/etc/postfix/mysql-virtual_sender_login_maps.cf
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $sender_bcc_maps $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_sasl_authenticated, permit_mynetworks, check_helo_access regexp:/etc/postfix/helo_access, reject_invalid_hostname, reject_non_fqdn_hostname, reject_invalid_helo_hostname, reject_unknown_helo_hostname, check_helo_access regexp:/etc/postfix/blacklist_helo
smtpd_sender_restrictions = check_sender_access regexp:/etc/postfix/tag_as_originating.re , permit_mynetworks, permit_sasl_authenticated, check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf, check_sender_access regexp:/etc/postfix/tag_as_foreign.re
smtpd_client_restrictions = check_client_access mysql:/etc/postfix/mysql-virtual_client.cf
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
maildrop_destination_recipient_limit = 1
virtual_transport = dovecot
header_checks = regexp:/etc/postfix/header_checks
mime_header_checks = regexp:/etc/postfix/mime_header_checks
nested_header_checks = regexp:/etc/postfix/nested_header_checks
body_checks = regexp:/etc/postfix/body_checks
owner_request_special = no
smtp_tls_security_level = may
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_protocols = !SSLv2,!SSLv3
smtp_tls_protocols = !SSLv2,!SSLv3
smtpd_tls_exclude_ciphers = RC4, aNULL
smtp_tls_exclude_ciphers = RC4, aNULL
dovecot_destination_recipient_limit = 1
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
content_filter = amavis:[127.0.0.1]:10024
receive_override_options = no_address_mappings
Postfix 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" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (no) (never) (100)
# ==========================================================================
smtp inet n - y - - smtpd
#smtp inet n - y - 1 postscreen
#smtpd pass - - y - - smtpd
#dnsblog unix - - y - 0 dnsblog
#tlsproxy unix - - y - 0 tlsproxy
submission inet n - y - - 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 smtpd_tls_auth_only=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
smtps inet n - y - - 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 smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#628 inet n - y - - qmqpd
pickup unix n - y 60 1 pickup
cleanup unix n - y - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
tlsmgr unix - - y 1000? 1 tlsmgr
rewrite unix - - y - - trivial-rewrite
bounce unix - - y - 0 bounce
defer unix - - y - 0 bounce
trace unix - - y - 0 bounce
verify unix - - y - 1 verify
flush unix n - y 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - y - - smtp
relay unix - - y - - smtp
-o syslog_name=postfix/$service_name
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - y - - showq
error unix - - y - - error
retry unix - - y - - error
discard unix - - y - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - y - - lmtp
anvil unix - - y - 1 anvil
scache unix - - y - 1 scache
postlog unix-dgram n - n - 1 postlogd
#
# ====================================================================
# 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 vmail ${extension} ${recipient} ${user} ${nexthop} ${sender}
#
# ====================================================================
#
# 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}
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}
amavis unix - - - - 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o smtp_bind_address=
127.0.0.1:10025 inet n - n - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
127.0.0.1:10027 inet n - n - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtp_send_xforward_command=yes
-o milter_default_action=accept
-o milter_macro_daemon_name=ORIGINATING
-o disable_dns_lookups=yes
- 尾部-f /var/log/mail.log:
postfix/smtpd[30136]: disconnect from localhost[::1] ehlo=1 auth=1 mail=1 rcpt=1 data=1 quit=1 commands=6
Jul 20 08:40:50 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30156, secured, session=<1yIO0d6qMroAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:40:50 echo dovecot: imap([email protected])<30156><1yIO0d6qMroAAAAAAAAAAAAAAAAAAAAB>: Logged out in=1128 out=1056 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Jul 20 08:40:50 echo postfix/smtpd[30159]: connect from localhost.localdomain[127.0.0.1]
Jul 20 08:40:50 echo postfix/smtpd[30159]: C36A7E08A8: client=localhost.localdomain[127.0.0.1]
Jul 20 08:40:50 echo postfix/cleanup[30094]: C36A7E08A8: message-id=<[email protected]>
Jul 20 08:40:50 echo postfix/smtpd[30159]: disconnect from localhost.localdomain[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Jul 20 08:40:50 echo postfix/qmgr[27585]: C36A7E08A8: from=<[email protected]>, size=1656, nrcpt=1 (queue active)
Jul 20 08:40:50 echo amavis[23070]: (23070-16) Passed CLEAN {RelayedOutbound}, ORIGINATING LOCAL [::1]:34068 <[email protected]> -> <[email protected]>, Queue-ID: 48F7EE089B, Message-ID: <[email protected]>, mail_id: ZkrJmYfgX0Jz, Hits: 0.213, size: 1191, queued_as: C36A7E08A8, 464 ms
Jul 20 08:40:50 echo postfix/smtp[30097]: 48F7EE089B: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10026, delay=0.54, delays=0.07/0/0.01/0.46, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10027): 250 2.0.0 Ok: queued as C36A7E08A8)
Jul 20 08:40:50 echo postfix/qmgr[27585]: 48F7EE089B: removed
Jul 20 08:40:50 echo postfix/smtp[30141]: C36A7E08A8: to=<[email protected]>, relay=mx.tb.mail.iss.as9143.net[212.54.42.8]:25, delay=0.14, delays=0.02/0/0.12/0, dsn=4.0.0, status=deferred (host mx.tb.mail.iss.as9143.net[212.54.42.8] refused to talk to me: 550 mx5.tb.mail.iss.as9143.net mx5.tb.mail.iss.as9143.net MXIN102 Your IP {HIDDEN_IP} is in RBL. Please see https://www.spamhaus.org/query/ip/{HIDDEN_IP} ;id=xV6AjHSqSlfIA;sid=xV6AjHSqSlfIA;mta=mx5.tb;d=20200720;t=144050[CET];ipsrc={HIDDEN_IP};)
Jul 20 08:40:51 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30162, secured, session=<Z0UZ0d6qOroAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:40:51 echo dovecot: imap([email protected])<30162><Z0UZ0d6qOroAAAAAAAAAAAAAAAAAAAAB>: Logged out in=70 out=654 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Jul 20 08:40:51 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30165, secured, session=<WPIc0d6qPLoAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:40:51 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30166, secured, session=<KRId0d6qProAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:40:51 echo dovecot: imap([email protected])<30166><KRId0d6qProAAAAAAAAAAAAAAAAAAAAB>: Logged out in=119 out=787 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Jul 20 08:40:51 echo dovecot: imap([email protected])<30165><WPIc0d6qPLoAAAAAAAAAAAAAAAAAAAAB>: Logged out in=317 out=6562 deleted=0 expunged=0 trashed=0 hdr_count=14 hdr_bytes=2388 body_count=0 body_bytes=0
Jul 20 08:40:52 echo postfix/qmgr[27585]: B9038E08FB: from=<[email protected]>, size=1042, nrcpt=1 (queue active)
Jul 20 08:40:53 echo postfix/smtp[30141]: B9038E08FB: to=<[email protected]>, relay=mx.tb.mail.iss.as9143.net[212.54.42.8]:25, delay=5170, delays=5170/0/0.16/0, dsn=4.0.0, status=deferred (host mx.tb.mail.iss.as9143.net[212.54.42.8] refused to talk to me: 550 mx2.tb.mail.iss.as9143.net mx2.tb.mail.iss.as9143.net MXIN102 Your IP {HIDDEN_IP} is in RBL. Please see https://www.spamhaus.org/query/ip/{HIDDEN_IP} ;id=xV6DjCowJQsUv;sid=xV6DjCowJQsUv;mta=mx2.tb;d=20200720;t=144053[CET];ipsrc={HIDDEN_IP};)
Jul 20 08:40:54 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30168, secured, session=<B99J0d6qQroAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:40:54 echo dovecot: imap([email protected])<30168><B99J0d6qQroAAAAAAAAAAAAAAAAAAAAB>: Logged out in=32 out=506 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Jul 20 08:40:54 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30170, secured, session=<UgNL0d6qRLoAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:40:54 echo dovecot: imap([email protected])<30170><UgNL0d6qRLoAAAAAAAAAAAAAAAAAAAAB>: Logged out in=44 out=613 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Jul 20 08:41:15 echo postfix/smtpd[30136]: connect from localhost[::1]
Jul 20 08:41:15 echo postfix/smtpd[30136]: NOQUEUE: filter: RCPT from localhost[::1]: <[email protected]>: Sender address triggers FILTER amavis:[127.0.0.1]:10026; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<_>
Jul 20 08:41:15 echo postfix/smtpd[30136]: 71BA4E08A3: client=localhost[::1], sasl_method=LOGIN, [email protected]
Jul 20 08:41:15 echo postfix/cleanup[30094]: 71BA4E08A3: message-id=<[email protected]>
Jul 20 08:41:15 echo postfix/qmgr[27585]: 71BA4E08A3: from=<[email protected]>, size=595, nrcpt=1 (queue active)
Jul 20 08:41:15 echo postfix/smtpd[30136]: disconnect from localhost[::1] ehlo=1 auth=1 mail=1 rcpt=1 data=1 quit=1 commands=6
Jul 20 08:41:15 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30187, secured, session=<zC2O0t6qSroAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:41:15 echo dovecot: imap([email protected])<30187><zC2O0t6qSroAAAAAAAAAAAAAAAAAAAAB>: Logged out in=460 out=670 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Jul 20 08:41:15 echo postfix/smtpd[30159]: connect from localhost.localdomain[127.0.0.1]
Jul 20 08:41:15 echo postfix/smtpd[30159]: AEDF6E08A2: client=localhost.localdomain[127.0.0.1]
Jul 20 08:41:15 echo postfix/cleanup[30094]: AEDF6E08A2: message-id=<[email protected]>
Jul 20 08:41:15 echo postfix/smtpd[30159]: disconnect from localhost.localdomain[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Jul 20 08:41:15 echo postfix/qmgr[27585]: AEDF6E08A2: from=<[email protected]>, size=1070, nrcpt=1 (queue active)
Jul 20 08:41:15 echo amavis[27021]: (27021-05) Passed CLEAN {RelayedOutbound}, ORIGINATING LOCAL [::1]:34094 <[email protected]> -> <[email protected]>, Queue-ID: 71BA4E08A3, Message-ID: <[email protected]>, mail_id: yi2HrBVrV9H1, Hits: 0.213, size: 595, queued_as: AEDF6E08A2, 211 ms
Jul 20 08:41:15 echo postfix/smtp[30097]: 71BA4E08A3: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10026, delay=0.29, delays=0.07/0/0.01/0.21, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10027): 250 2.0.0 Ok: queued as AEDF6E08A2)
Jul 20 08:41:15 echo postfix/qmgr[27585]: 71BA4E08A3: removed
Jul 20 08:41:16 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30190, secured, session=<pjKZ0t6qULoAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:41:16 echo dovecot: imap([email protected])<30190><pjKZ0t6qULoAAAAAAAAAAAAAAAAAAAAB>: Logged out in=70 out=654 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Jul 20 08:41:16 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30193, secured, session=<wB6e0t6qUroAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:41:16 echo dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=30194, secured, session=<u2ie0t6qVLoAAAAAAAAAAAAAAAAAAAAB>
Jul 20 08:41:16 echo dovecot: imap([email protected])<30194><u2ie0t6qVLoAAAAAAAAAAAAAAAAAAAAB>: Logged out in=119 out=795 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Jul 20 08:41:16 echo dovecot: imap([email protected])<30193><wB6e0t6qUroAAAAAAAAAAAAAAAAAAAAB>: Logged out in=317 out=6982 deleted=0 expunged=0 trashed=0 hdr_count=15 hdr_bytes=2563 body_count=0 body_bytes=0
Jul 20 08:41:45 echo postfix/smtp[30141]: connect to gmail-smtp-in.l.google.com[74.125.143.27]:25: Connection timed out
Jul 20 08:41:45 echo postfix/smtp[30141]: connect to gmail-smtp-in.l.google.com[2a00:1450:4013:c04::1a]:25: Network is unreachable
但是,我在此日志中看到电子邮件已成功发送给收件人(不是从外部地址接收的),但为什么它一直尝试通过端口 25?我的 ISP 阻止了它,我想强制使用端口 587,因为这样它可以在任何环境、多个服务/ISP 中工作。此外,我看到很多基于 Gmail 的服务的结果Network is unreachable
,Connection timed out
当它通过正确的端口连接时,这个问题解决了吗?
我也无法使用 Dovecot 在此服务器上接收任何邮件。有没有其他方法可以解决这个问题,因为我找不到任何关于它为什么不起作用的错误响应?
我还从 Roundcube 获得了关于发送是否有意义的诊断代码:
smtp; 554 5.7.1 <unknown[192.168.1.1]>: Client host rejected:
Access denied
如果有人能帮助我解决这个问题,我将不胜感激
答案1
希望这对你有帮助: 例如,您有:
- 领域:我的域名.com
- 邮件域名:mail.mydomain.com
- 静态IP:123.123.123.123
- 大都会运输署:后缀
这里需要多花一点努力:
- 互联网服务提供商
- 向您的 ISP 索取 IP 即 123.123.123.123 到 mail.mydomain.com 的反向记录 (PTR)
- 要求您的 ISP 打开 IP 123.123.123.123 的 smtp 端口(如果您希望使用多个 IP 进行故障转移,也请打开 dns 端口)
- 控制面板
添加记录:类型:A生存时间(TTL):3600主持人:mail.mydomain.com指着:123.123.123.123
添加MX 记录:类型:墨西哥生存时间(TTL):3600主持人:我的域名优先事项:10分到:mail.mydomain.com
添加MX 记录:类型:墨西哥生存时间(TTL):3600主持人:我的域名优先事项:20 分到:我的域名
配置SPF + DKIM + DMARC在 cPANEL 中记录 ( dkim + dmarc 生成器)
检查并从中删除您的 IP 123.123.123.123黑名单網站。
- 邮件服务器
主机名:mail.mydomain.com
防火墙开放端口:80,443,25,143,587,993,995 用于电子邮件
添加软件包 fail2ban(防止外部攻击)、policyd(限制传入和传出电子邮件)、claimav(病毒扫描)
我的邮件服务器工作配置(适用于 centos7):
后配置-n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
bounce_notice_recipient = [email protected]
broken_sasl_auth_clients = no
command_directory = /usr/sbin
config_directory = /etc/postfix
content_filter = smtp-amavis:[127.0.0.1]:10024
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
default_destination_concurrency_limit = 30
default_destination_rate_delay = 5s
disable_vrfy_command = yes
dovecot_destination_recipient_limit = 1
enable_original_recipient = no
fast_flush_domains = $mydomain
html_directory = no
inet_interfaces = all
inet_protocols = ipv4
insiders_only = check_sender_access hash:/etc/postfix/insiders, reject
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
message_size_limit = 5242880
milter_default_action = accept
mydestination = $myhostname
mydomain = mydomain.com
myhostname = mail.mydomain.com
mynetworks = cidr:/etc/postfix/network_table
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
non_smtpd_milters = $smtpd_milters
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
relay_recipient_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_tls_loglevel = 1
smtp_tls_security_level = may
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name. Send us your mail..not your spam!!
smtpd_client_connection_count_limit = 30
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_delay_reject = yes
smtpd_end_of_data_restrictions = check_policy_service inet:127.0.0.1:10031
smtpd_etrn_restrictions = permit_mynetworks, reject
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, permit
smtpd_milters = inet:127.0.0.1:8891
smtpd_recipient_limit = 30
smtpd_recipient_restrictions = check_policy_service inet:127.0.0.1:10031, check_recipient_access hash:/etc/postfix/protected_destinations, hash:/etc/postfix/bad_recipients, check_sender_access hash:/etc/postfix/sender_access, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_unauth_pipelining, reject_unknown_reverse_client_hostname, reject_invalid_helo_hostname, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_invalid_hostname, reject_rbl_client zen.spamhaus.org, reject_rbl_client bl.spamcop.net, reject_rbl_client b.barracudacentral.org, permit
smtpd_reject_footer = \c. For assistance, Please provide the following information in your problem report: time ($localtime), client ($client_address) and server ($server_name).
smtpd_restriction_classes = insiders_only
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_login_maps = $virtual_mailbox_maps
smtpd_sender_restrictions = check_policy_service inet:127.0.0.1:10031, reject_sender_login_mismatch, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_sender, reject_unknown_sender_domain, permit
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/pki/tls/certs/mydomain.com.crt
smtpd_tls_key_file = /etc/pki/tls/private/mydomain.com.key
smtpd_tls_loglevel = 1
smtpd_tls_security_level = may
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
virtual_alias_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_gid_maps = static:12
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_minimum_uid = 150
virtual_transport = dovecot
virtual_uid_maps = static:150
doveconf-n
# 2.2.36 (1f10bfa63): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.24 (124e06aa)
doveconf: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf
doveconf: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:30: 'imaps' protocol is no longer necessary, remove it
doveconf: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf
doveconf: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:30: 'imaps' protocol is no longer necessary, remove it
doveconf: Warning: service auth { client_limit=3000 } is lower than required under max. load (4000)
doveconf: Warning: service anvil { client_limit=3000 } is lower than required under max. load (3003)
# OS: Linux 3.10.0-693.21.1.el7.x86_64 x86_64 CentOS Linux release 7.4.1708 (Core) xfs
# Hostname: mail.mydomain.com
auth_default_realm = mydomain.com
auth_failure_delay = 5 secs
auth_mechanisms = plain login
auth_realms = mydomain.com
auth_verbose = yes
default_client_limit = 3000
default_process_limit = 1000
dict {
sqldomainquota = mysql:/etc/dovecot/dovecot-sql-domain.conf
sqluserquota = mysql:/etc/dovecot/dovecot-dict-sql-user.conf
}
first_valid_gid = 12
first_valid_uid = 150
last_valid_gid = 12
last_valid_uid = 150
listen = *,::
log_path = /var/log/dovecot.log
mail_debug = yes
mail_gid = mail
mail_location = maildir:/home/vmail/%d/%n
mail_plugins = " quota"
mail_privileged_group = mail
mail_uid = vmail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext
mbox_write_locks = fcntl
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
special_use = \Trash
}
prefix =
}
passdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
plugin {
quota = dict:User Quota::proxy::sqluserquota
sieve = file:~/sieve;active=~/.dovecot.sieve
sieve_default = /var/lib/dovecot/sieve/default.sieve
sieve_dir = ~/.sieve
sieve_global_dir = /var/lib/dovecot/sieve/
}
postmaster_address = [email protected]
protocols = imap sieve
service auth-worker {
user = vmail
}
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0666
user = postfix
}
unix_listener auth-userdb {
mode = 0600
user = vmail
}
user = dovecot
}
service dict {
unix_listener dict {
mode = 0600
user = vmail
}
}
service imap-login {
inet_listener imaps {
port = 993
ssl = yes
}
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
}
}
service managesieve-login {
inet_listener sieve {
port = 4190
}
}
ssl_cert = </etc/pki/tls/certs/mydomain.com.crt
ssl_key = # hidden, use -P to show it
userdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
verbose_proctitle = yes
protocol lda {
mail_plugins = " quota sieve quota"
}
protocol imap {
mail_plugins = " quota imap_quota"
}
protocol pop3 {
mail_plugins = " quota quota"
}
Roundcube 配置
<?php
$config['db_dsnw'] = 'mysql://user:password@localhost/database';
$config['default_host'] = 'imaps://localhost';
$config['smtp_server'] = 'tls://localhost';
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['support_url'] = '';
$config['des_key'] = '5d4eed1d4eddizHjz6i6GTLb';
$config['username_domain'] = 'mydomain.com';
$config['product_name'] = 'Roundcube WebMail';
$config['plugins'] = array('archive','filters', 'globaladdressbook', 'hide_blockquote', 'identicon', 'jqueryui', 'markasjunk', 'new_user_identity', 'newmail_notifier', 'show_additional_headers','managesieve', 'zipdownload');
//clears trash when user logs out (if true)
#$config['logout_purge'] = true;
$config['default_port'] = 993;
$config['max_message_size'] = '5M';
这关联如果你正在使用 debian,这可能会有所帮助。
答案2
几天前,我刚开始研究 DNS,因为我对它不熟悉。之后我得出结论,要添加 SPF 记录、DKIM 和 DMARC。此外,由于我的日志显示我的 IP 在 RBL 中,我不认为这是问题所在,因为他们有 RBL 解释。但我请求删除该 IP,从那时起,这个问题就通过我的邮件服务器和 ISP 之间的邮件得到了解决。
由于有更多的电子邮件提供商都显示相同的消息:
connect to gmail-smtp-in.l.google.com[74.125.143.27]:25: Connection timed out
Jul 20 08:41:45 echo postfix/smtp[30141]: connect to gmail-smtp-in.l.google.com[2a00:1450:4013:c04::1a]:25: Network is unreachable
这类问题似乎有一个常见的解决方案,并且已经被回答了很多次;
• 变成inet_protocols = all
你inet_protocols = ipv4
的/etc/postfix/main.cf
重新启动、重新加载并刷新 Postfix 后,测试再次失败,发送到 Gmail 时再次出现同样的错误。
然后我通过这篇文章找到了另一个可能的解决方案https://superuser.com/questions/1069049/postfix-problems-sending-mail-to-gmail-addresses
• 更改relayhost =
为relayhost = smtp.myisp.ext:25
我再次测试向我的多个地址发送邮件;ISP、Gmail、Outlook、Yahoo,并且成功发送!