大网数据广告活动
服务器运维问答

How to trace/find "lost" emails with log files and doveadm?

· 52CE 我爱测

One of my clients is missing some emails and I try to find what is going on, but my knowledge is limited. Have asked the server support guys, but they say all is fine and attach just the logs (which I can't read well > ♻️ ) What …

问题原文

原帖链接 · Sam · CC BY-SA 4.0

One of my clients is missing some emails and I try to find what is going on, but my knowledge is limited. Have asked the server support guys, but they say all is fine and attach just the logs (which I can't read well > ♻️ )

What have I done?.

root@myserver:~# zgrep [email omitted] /var/log/mail.log.2.gz

There I see mails, and they get a queue and message ID attached:

Queue-ID: 2125915E4BB, Message-ID: <[email omitted]>

Log

root@myserver:~# cat /var/log/mail.* |egrep '4525915E4AA|6B02315A8FE|E511515E3FF' |sort
Nov  2 09:48:40 myserver postfix/cleanup[8085]: 4525915E4AA: message-id=<[email omitted]>
Nov  2 09:48:40 myserver postfix/qmgr[9669]: 4525915E4AA: from=<[email omitted]>, size=297312, nrcpt=1 (queue active)
Nov  2 09:48:40 myserver postfix/submission/smtpd[8275]: 4525915E4AA: client=myserver.host.com[123.123.123.1], sasl_method=LOGIN, sasl_username=[email omitted]
Nov  2 09:48:44 myserver amavis[4102]: (04102-12) Passed CLEAN {RelayedInbound}, [123.123.123.1]:59776 [123.123.123.1] <[email omitted]> -> <[email omitted]>, Queue-ID: 4525915E4AA, Message-ID: <[email omitted]>, mail_id: NfX3Lgs8fYbm, Hits: -1.945, size: 297832, queued_as: A3CC315E4B5, 4282 ms
Nov  2 09:48:44 myserver postfix/qmgr[9669]: 4525915E4AA: removed
Nov  2 09:48:44 myserver postfix/smtp[8276]: 4525915E4AA: to=<[email omitted]>, relay=127.0.0.1[127.0.0.1]:10024, delay=4.5, delays=0.15/0.02/0/4.3, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as A3CC315E4B5)

# A3CC315E4B5
Nov  2 09:48:44 myserver postfix/smtpd[8094]: A3CC315E4B5: client=localhost.localdomain[127.0.0.1]
Nov  2 09:48:44 myserver postfix/cleanup[8085]: A3CC315E4B5: message-id=<[email omitted]>
Nov  2 09:48:44 myserver postfix/qmgr[9669]: A3CC315E4B5: from=<[email omitted]>, size=298519, nrcpt=1 (queue active)
Nov  2 09:48:44 myserver amavis[4102]: (04102-12) Passed CLEAN {RelayedInbound}, [123.123.123.1]:59776 [123.123.123.1] <[email omitted]> -> <[email omitted]>, Queue-ID: 4525915E4AA, Message-ID: <[email omitted]>, mail_id: NfX3Lgs8fYbm, Hits: -1.945, size: 297832, queued_as: A3CC315E4B5, 4282 ms
Nov  2 09:48:44 myserver postfix/smtp[8276]: 4525915E4AA: to=<[email omitted]>, relay=127.0.0.1[127.0.0.1]:10024, delay=4.5, delays=0.15/0.02/0/4.3, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as A3CC315E4B5)
Nov  2 09:48:44 myserver postfix/lmtp[8095]: A3CC315E4B5: to=<[email omitted]>, relay=myserver.host.com[private/dovecot-lmtp], delay=0.13, delays=0.06/0/0.01/0.06, dsn=2.0.0, status=sent (250 2.0.0 <[email omitted]> uLYULOwuYmNdIAAAPVEKtg Saved)
Nov  2 09:48:44 myserver postfix/qmgr[9669]: A3CC315E4B5: removed

How can I trace where the email has gone? Would it be possible to search for the email with doveadm? Or can I see, in the logs, if the email has been deleted by the user knowingly or unknowingly?

Where can I find more to know how to read those logs and what is going on? I know mail servers are complicated, but I wouldn't like to just tell my client “everything is fine” it is unclear to me why your emails are lost. Isn't much trustworthy, is it?

已采纳解答

原帖链接 · anx · CC BY-SA 4.0

Users may sometimes complain that they have lost emails. The problem is almost always that this was done by one of the user’s email clients accidentally. Especially accidentally configuring a “POP3 client” to a new device that deletes the mails after downloading them. -- Dovecot manual: Mail Debugging

There is a chance that you are not logging individual IMAP actions, so might not be able to track which user has removed a message. If you however learn that the missing messages are all older than X days and one user with access has recently setup a mail client with a feature to discard old messages, that would quickly pinpoint a suspect.

How can I trace where the email has gone?

You did, you just have to continue as there are at least four different identifiers.

  1. You got [email omitted] indicated in the Message-ID header, that is what the sending software attached.
  2. Postfix first receives this, tracks it as 4525915E4AA.
  3. Postfix hands it for Amavis, which is fine with forwarding it, and hands it back to Postfix. Now Postfix tracks it as A3CC315E4B5.
  4. Postfix must have determined the recipient is local, so it handed it to Dovecot, the IMAP server. Dovecot reported back that it received it fully, is accepting responsibility for not losing it, and will be tracking that message as uLYULOwuYmNdIAAAPVEKtg.

Up until the part that you quoted, the message was not lost - yet. Keep tracking the chain until you reach the end of reported transmissions. Dovecot may or may not have tried to store the message, and may or may not have lost or intentionally deleted on user request later on.

I suspect if you search your logs for the identifier 4, you will find a log entry where Dovecot reports what user and mailbox (namespace/subfolder) the message was stored in, plus another quote of the message-id header.

Would it be possible to search for the email with doveadm?

If Dovecot still has your message, it will be able to locate it. Might want to limit your search to reasonable subsets if the mailboxes are more than a few hundred gigabytes, specifics are detailed in the doveadm search and doveadm search-query manual. Example:

doveadm fetch -u [email omitted] 'hdr.date mailbox' HEADER Message-ID '[email omitted]'
# if that is appropriate and properly setup, you might even search all users:
doveadm fetch -A 'hdr.date mailbox' HEADER Message-ID '[email omitted]'

If the message was delivered, then lost, the type of mail storage and the users with permissions might be relevant in further inquiry. For potential follow-up questions about ways a mailbox might have gotten corrupted or inaccessible, be sure to include relevant configuration, such as dumped by the doveconf -n command.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-11-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。