Dovecot + Postfix 可以发送但电子邮件不会显示在收件箱中

Dovecot + Postfix 可以发送但电子邮件不会显示在收件箱中

我正在尝试在我的个人网站服务器上设置电子邮件服务器。我大部分时间都在那里,我可以发送电子邮件,但向我设置的地址发送电子邮件似乎不会用新文件填充cur或目录new中的目录。虽然发送电子邮件后会填充(这似乎总是成功)。InboxJunkSent

相关软件包的守护进程处于活动状态,似乎没有任何警告/错误。MX 记录等似乎没问题,DKIM 测试表明一切正常,而且我也不在任何垃圾邮件列表中。此时,我基本上已经迷失了。

我在个人服务器上使用 Arch Linux,其软件包版本如下:

postfix 3.5.6-1
dovecot 2.3.10.1-2
opendkim 2.10.3-7
pigeonhole 0.5.10-2
procmail 3.22-10
spamassassin 3.4.4-3

这是系统日志的一部分(我认为 postfix 不允许有自己的日志?)。这似乎是唯一有价值信息的部分,尽管我不明白。某种 milter 问题?(此外,我还替换了个人身份信息,例如 IP 和域名)

Aug 05 13:01:29 user postfix/cleanup[94749]: 836A924F0B: message-id=<[email protected]>
Aug 05 13:01:29 user postfix/qmgr[94666]: 836A924F0B: from=<[email protected]>, size=499, nrcpt=1 (queue active)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: public/cleanup socket: wanted attribute: status
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: status
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute value: 0
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: public/cleanup socket: wanted attribute: reason
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: reason
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute value: (end)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: public/cleanup socket: wanted attribute: (list terminator)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: (end)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: > unknown[666.666.666.666]: 250 2.0.0 Ok: queued as 836A924F0B
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: abort all milters
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: milter8_abort: abort milter inet:127.0.0.1:12301
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: < unknown[666.666.666.666]: QUIT
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: > unknown[666.666.666.666]: 221 2.0.0 Bye
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_hostname: smtpd_client_event_limit_exceptions: unknown ~? 127.0.0.1/32Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_hostaddr: smtpd_client_event_limit_exceptions: 666.666.666.666 ~? 127.0.0.1/32
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_hostname: smtpd_client_event_limit_exceptions: unknown ~? 777.777.777.777/32
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_hostaddr: smtpd_client_event_limit_exceptions: 666.666.666.666 ~? 777.777.777.777/32
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_list_match: unknown: no match
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: match_list_match: 666.666.666.666: no match
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: send attr request = disconnect
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: send attr ident = submission666.666.666.666:
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: private/anvil: wanted attribute: status
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: status
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute value: 0
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: private/anvil: wanted attribute: (list terminator)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: input attribute name: (end)
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: abort all milters
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: milter8_abort: abort milter inet:127.0.0.1:12301
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: disconnect event to all milters
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: milter8_disc_event: quit milter inet:127.0.0.1:12301
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: disconnect from unknown[666.666.666.666] ehlo=2 starttls=1 auth=1 mail=1 rcpt=1 data=1 quit=1 commands=8
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: free all milters
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: free milter inet:127.0.0.1:12301
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: master_notify: status 1
Aug 05 13:01:29 user postfix/submission/smtpd[94741]: connection closed
Aug 05 13:01:29 user postfix/smtp[94750]: 836A924F0B: to=<[email protected]>, relay=none, delay=0.38, delays=0.21/0.06/0.11/0, dsn=5.4.6, status=bounced (mail for domain.com loops back to myself)
Aug 05 13:01:30 user postfix/cleanup[94749]: 00DA924F0E: message-id=<[email protected]>
Aug 05 13:01:30 user postfix/bounce[94751]: 836A924F0B: sender non-delivery notification: 00DA924F0E
Aug 05 13:01:30 user postfix/qmgr[94666]: 00DA924F0E: from=<>, size=2965, nrcpt=1 (queue active)
Aug 05 13:01:30 user postfix/qmgr[94666]: 836A924F0B: removed
Aug 05 13:01:30 user postfix/smtp[94750]: 00DA924F0E: to=<[email protected]>, relay=none, delay=0.06, delays=0.02/0/0.04/0, dsn=5.4.6, status=bounced (mail for domain.com loops back to myself)
Aug 05 13:01:30 user postfix/qmgr[94666]: 00DA924F0E: removed

我已经打开了必要的端口并进行了验证。在线端口检查工具确认。这里 (v6)

端口监听似乎按预期工作。以下是lsof -iTCP -sTCP:LISTEN -P

COMMAND     PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
dovecot   92963     root   21u  IPv4 963311      0t0  TCP *:110 (LISTEN)
dovecot   92963     root   22u  IPv6 963312      0t0  TCP *:110 (LISTEN)
dovecot   92963     root   23u  IPv4 963313      0t0  TCP *:995 (LISTEN)
dovecot   92963     root   24u  IPv6 963314      0t0  TCP *:995 (LISTEN)
dovecot   92963     root   39u  IPv4 963359      0t0  TCP *:143 (LISTEN)
dovecot   92963     root   40u  IPv6 963360      0t0  TCP *:143 (LISTEN)
dovecot   92963     root   41u  IPv4 963361      0t0  TCP *:993 (LISTEN)
dovecot   92963     root   42u  IPv6 963362      0t0  TCP *:993 (LISTEN)
master    93066     root   88u  IPv4 964097      0t0  TCP *:25 (LISTEN)
master    93066     root   91u  IPv4 964100      0t0  TCP *:587 (LISTEN)
master    93066     root   94u  IPv4 964103      0t0  TCP *:465 (LISTEN)
opendkim  93089 opendkim    3u  IPv4 964461      0t0  TCP localhost:12301 (LISTEN)
spamd     93121     root    6u  IPv6 964939      0t0  TCP localhost:783 (LISTEN)
spamd     93121     root    7u  IPv4 964941      0t0  TCP localhost:783 (LISTEN)
spamd\x20 93144    spamd    6u  IPv6 964939      0t0  TCP localhost:783 (LISTEN)
spamd\x20 93144    spamd    7u  IPv4 964941      0t0  TCP localhost:783 (LISTEN)
spamd\x20 93145    spamd    6u  IPv6 964939      0t0  TCP localhost:783 (LISTEN)
spamd\x20 93145    spamd    7u  IPv4 964941      0t0  TCP localhost:783 (LISTEN)
smtp      93244  postfix    6u  IPv4 964097      0t0  TCP *:25 (LISTEN)

以下是 postfix main.cf 的内容

compatibility_level = 2
queue_directory = /var/spool/postfix
command_directory = /usr/bin
daemon_directory = /usr/lib/postfix/bin
data_directory = /var/lib/postfix
mail_owner = postfix
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/postfix/aliases
alias_database = $alias_maps
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
sendmail_path = /usr/bin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /etc/postfix
readme_directory = /usr/share/doc/postfix
inet_protocols = ipv4
meta_directory = /etc/postfix
shlib_directory = /usr/lib/postfix
smtpd_tls_key_file = /etc/letsencrypt/live/mail.domain.com/privkey.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.domain.com/fullchain.pem
smtpd_use_tls = yes
smtpd_tls_auth_only = yes
smtp_tls_security_level = may
smtp_tls_loglevel = 1
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
home_mailbox = ~/Mail/Inbox/
#smtpd_milters = inet:localhost:12301 #Can't find localhost? is there some issue with /etc/hosts?
#non_smtpd_milters = inet:localhost:12301
#127.0.0.1 should work anyway I think
smtpd_milters = inet:127.0.0.1:12301
non_smtpd_milters = inet:127.0.0.1:12301
smtpd_sasl_security_options = noanonymous, noplaintext
smtpd_sasl_tls_security_options = noanonymous
myhostname = mail.domain.com
milter_default_action = accept
milter_protocol = 6

以下是 master.cf 的内容

pickup    unix  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
relay     unix  -       -       n       -       -       smtp
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
postlog   unix-dgram n  -       n       -       1       postlogd
smtp unix - - n - - smtp 
smtp inet n - y - - smtp -v
  -o content_filter=spamassassin 
submission inet n       -       y       -       -       smtpd -v
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_tls_auth_only=yes
submissions     inet  n       -       y       -       -       smtpd -v
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
spamassassin unix -     n       n       -       -       pipe
  user=spamd argv=/usr/bin/vendor_perl/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}" 

以下是 dovecot.conf 的内容

ssl = required
ssl_cert = </etc/letsencrypt/live/mail.domain.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.domain.com/privkey.pem
ssl_dh = </etc/dovecot/dh.pem

auth_mechanisms = plain login
protocols = $protocols imap
disable_plaintext_auth = no
mail_privileged_group = mail

userdb {
        driver = passwd
}
passdb {
        driver = pam
        args = session=yes failure_show_msg=yes
}


mail_location = maildir:~/Mail:INBOX=~/Mail/Inbox:LAYOUT=fs
namespace inbox {
        inbox = yes
       
        mailbox Drafts {
        special_use = \Drafts
        auto = create
        }

        mailbox Junk {
        special_use = \Junk
        auto = create
        autoexpunge = 30d
        }
        
        mailbox Sent {
        special_use = \Sent
        auto = create
        }

        mailbox Trash {
        special_use = \Trash
        auto = create
        }

        mailbox Archive {
        special_use = \Archive
        auto = create
        }
        mailbox Done {
        auto = create
        }
}

service auth {
  unix_listener /var/spool/postfix/private/auth {
        mode = 0660
        user = postfix
        group = postfix
    }
}

protocol lda {
  mail_plugins = $mail_plugins sieve
}

protocol lmtp {
  mail_plugins = $mail_plugins sieve
}

plugin {
        sieve = ~/.dovecot.sieve
        sieve_default = /var/lib/dovecot/sieve/default.sieve
        sieve_dir = ~/.sieve
        sieve_global_dir = /var/lib/dovecot/sieve/
}

#Logging
log_path = /var/log/dovecot.log
auth_verbose = yes
mail_debug = yes
auth_debug = yes
auth_debug_passwords = yes
verbose_ssl=yes

/etc/postfix/aliases 的内容

mailer-daemon: postmaster
postmaster: root
root: user 
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root

/var/lib/dovecot/sieve/default.sieve 的内容

require ["fileinto", "mailbox"];
if header :contains "X-Spam-Flag" "YES"
        {
                fileinto "Junk";
        }   

/etc/opendkim/opendkim.conf 的内容

BaseDirectory           /var/lib/opendkim
Domain                  tzcrawford.com
KeyFile                 /etc/opendkim/mail.private
Selector                mail
Socket                  inet:12301@localhost
Syslog                  Yes
TemporaryDirectory      /run/opendkim
UMask                   002
Canonicalization        relaxed/simple
KeyTable file:/etc/opendkim/keytable
SigningTable refile:/etc/opendkim/signingtable
InternalHosts refile:/etc/opendkim/trustedhost

如果您有任何想法或想要更多信息,请告诉我,谢谢!

答案1

Postfix 尚未配置为接受您域名的邮件,因此当它查找域的 MX 记录并发现它指定自己作为要投递的邮件服务器时,它会抛出错误“邮件回环到我自己”。因为它实际上并不接受您域名的邮件,所以它唯一能做的就是退回邮件。

然后我们看到退回邮件本身也被退回,原因相同。随后发生的事情出现在您未发布的后续日志条目中,但通常此类邮件会被丢弃或记录在某处。

您需要配置 Postfix 以接受您的域名的邮件。这需要设置 obthmyorigin=指令main.cf,应设置为$mydomainmydestination=指令,其中应包括本地发送邮件的几个值:

myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain $mydomain

相关内容