Postfix/Dovecot 在 Ubuntu 16.04 中无法接收外部电子邮件

Postfix/Dovecot 在 Ubuntu 16.04 中无法接收外部电子邮件

我已阅读所有帖子,但无法找出问题所在。我可以发送电子邮件。我可以从本地主机和同一域的其他电子邮件名称接收电子邮件,但我无法接收来自外部电子邮件(如 Gmail 等)的电子邮件。

所有内容均已发送并经过验证,但未收到任何内容。

以下是 Dovecot 和 Postfix 的配置:

sudo doveconf -n
# 2.3.14 (cee3cbc0d): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.14 (1b5c82b2)
# OS: Linux 4.15.0-29-generic x86_64 Ubuntu 18.04.5 LTS
# Hostname: nameofthehost
auth_mechanisms = plain login
dict {
  sqlquota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
}
first_valid_uid = 5000
last_valid_uid = 5000
mail_gid = vmail
mail_location = mbox:~/mail:INBOX=/var/mail/%u
mail_plugins = quota
mail_privileged_group = vmail
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 imapsieve vnd.dovecot.imapsieve
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 Spam {
    auto = subscribe
    special_use = \Junk
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  imapsieve_mailbox1_before = file:/var/mail/vmail/sieve/global/report-spam.sieve
  imapsieve_mailbox1_causes = COPY
  imapsieve_mailbox1_name = Spam
  imapsieve_mailbox2_before = file:/var/mail/vmail/sieve/global/report-ham.sieve
  imapsieve_mailbox2_causes = COPY
  imapsieve_mailbox2_from = Spam
  imapsieve_mailbox2_name = *
  quota = dict:User quota::proxy::sqlquota
  quota_exceeded_message = Quota exceeded, please contact your system administrator.
  quota_grace = 10%%
  quota_rule = *:storage=5GB
  quota_rule2 = Trash:storage=+100M
  quota_warning = storage=100%% quota-warning 100 %u
  quota_warning2 = storage=95%% quota-warning 95 %u
  quota_warning3 = storage=90%% quota-warning 90 %u
  quota_warning4 = storage=85%% quota-warning 85 %u
  sieve = file:/var/mail/vmail/sieve/%d/%n/scripts;active=/var/mail/vmail/sieve/%d/%n/active-script.sieve
  sieve_before = /var/mail/vmail/sieve/global/spam-global.sieve
  sieve_global_extensions = +vnd.dovecot.pipe
  sieve_pipe_bin_dir = /usr/bin
  sieve_plugins = sieve_imapsieve sieve_extprograms
}
protocols = " imap lmtp sieve pop3"
service auth-worker {
  user = vmail
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
  unix_listener auth-userdb {
    group = vmail
    mode = 0600
    user = vmail
  }
}
service dict {
  unix_listener dict {
    group = vmail
    mode = 0660
    user = vmail
  }
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
  }
}
service managesieve-login {
  inet_listener sieve {
    port = 4190
  }
}
service managesieve {
  process_limit = 1024
}
service quota-warning {
  executable = script /usr/local/bin/quota-warning.sh
  unix_listener quota-warning {
    group = vmail
    mode = 0660
    user = vmail
  }
  user = vmail
}
ssl_cert = </etc/letsencrypt/live/mydomain.com/fullchain.pem
ssl_cipher_list = EECDH+AES:EDH+AES+aRSA
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
ssl_prefer_server_ciphers = yes
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
protocol lmtp {
  mail_plugins = quota sieve
  postmaster_address = [email protected]
}
protocol imap {
  mail_plugins = quota imap_quota imap_sieve
}
postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
compatibility_level = 2
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
milter_default_action = accept
milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_authen}
milter_protocol = 6
mydestination = localhost.$mydomain, localhost, $mydomain
myhostname = nameofthehost
myorigin = /etc/mailname
non_smtpd_milters = inet:127.0.0.1:11332
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_milters = inet:127.0.0.1:11332
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_cert_file = /etc/letsencrypt/live/mydomain.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mydomain.com/privkey.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = no
virtual_alias_maps = mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp

我该如何调试?我该如何开始接收电子邮件?

更新:

当我从 Gmail 发送邮件时,我收到邮件已被送达的消息:

Message ID  <CALJ3QLOrZD5GhaaaFiXO5xZp+=sjSa1+PF5w=DBgozHB5qEu3A@mail.gmail.com>
Created on: 18 May 2023 at 11:16 (Delivered after 0 seconds)

文件如下mail.log

May 18 11:15:39 3b15 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=4319, secured, session=<8kXxaPP7Yt4AAAAAAAAAAAAAAAAAAAAB>
May 18 11:15:39 3b15 dovecot: imap([email protected])<4319><8kXxaPP7Yt4AAAAAAAAAAAAAAAAAAAAB>: Logged out in=90 out=972 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
May 18 11:16:41 3b15 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=4331, secured, session=<hkGZbPP7dN4AAAAAAAAAAAAAAAAAAAAB>
May 18 11:16:41 3b15 dovecot: imap([email protected])<4331><hkGZbPP7dN4AAAAAAAAAAAAAAAAAAAAB>: Logged out in=90 out=972 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
May 18 11:17:23 3b15 postfix/anvil[4241]: statistics: max connection rate 1/60s for (smtps:212.83.8.79) at May 18 11:14:03
May 18 11:17:23 3b15 postfix/anvil[4241]: statistics: max connection count 1 for (smtps:212.83.8.79) at May 18 11:14:03
May 18 11:17:23 3b15 postfix/anvil[4241]: statistics: max cache size 1 at May 18 11:14:03
May 18 11:17:39 3b15 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=4402, secured, session=<OsMWcPP7it4AAAAAAAAAAAAAAAAAAAAB>
May 18 11:17:39 3b15 dovecot: imap([email protected])<4402><OsMWcPP7it4AAAAAAAAAAAAAAAAAAAAB>: Logged out in=90 out=972 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
May 18 11:18:01 3b15 postfix/pickup[4122]: 8D50342261: uid=33 from=<www-data>
May 18 11:18:01 3b15 postfix/cleanup[4411]: 8D50342261: message-id=<[email protected]>
May 18 11:18:01 3b15 postfix/qmgr[4123]: 8D50342261: from=<[email protected]>, size=745, nrcpt=1 (queue active)
May 18 11:18:01 3b15 postfix/smtp[4413]: 8D50342261: to=<[email protected]>, orig_to=<www-data>, relay=none, delay=0.09, delays=0.06/0.03/0.01/0, dsn=5.4.6, status=bounced (mail for som.time4vps.cloud loops back to myself)
May 18 11:18:01 3b15 postfix/cleanup[4411]: A04B742262: message-id=<[email protected]>
May 18 11:18:01 3b15 postfix/qmgr[4123]: A04B742262: from=<>, size=3524, nrcpt=1 (queue active)
May 18 11:18:01 3b15 postfix/bounce[4414]: 8D50342261: sender non-delivery notification: A04B742262
May 18 11:18:01 3b15 postfix/qmgr[4123]: 8D50342261: removed
May 18 11:18:01 3b15 postfix/smtp[4413]: A04B742262: to=<[email protected]>, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=5.4.6, status=bounced (mail for som.time4vps.cloud loops back to myself)
May 18 11:18:01 3b15 postfix/qmgr[4123]: A04B742262: removed

我尝试过改变mydestination = localhost.$mydomain, localhost, mail.$mydomain, $mydomain但仍然没有成功。

答案1

我向注释中指定的地址发送了一条消息。以下是来自我的外发 MTA 的日志:

May 18 12:04:09 eli postfix/smtp[19064]: connect to _dc-mx.e81f8d7bf4a5.ognyanyankov.com[2606:4700:3033::ac43:c709]:25: Connection timed out
May 18 12:04:39 eli postfix/smtp[19064]: connect to _dc-mx.e81f8d7bf4a5.ognyanyankov.com[104.21.44.110]:25: Connection timed out
May 18 12:05:09 eli postfix/smtp[19064]: connect to _dc-mx.e81f8d7bf4a5.ognyanyankov.com[172.67.199.9]:25: Connection timed out
May 18 12:05:39 eli postfix/smtp[19064]: 20A222E015B: to=<[email protected]>, relay=none, delay=120, delays=0.18/0.03/120/0, dsn=4.4.1, status=deferred (connect to _dc-mx.e81f8d7bf4a5.ognyanyankov.com[2606:4700:3032::6815:2c6e]:25: Connection timed out)

有东西阻止了连接。这也会导致邮件无法投递。

相关内容