Score:1

How to retrieve non-delivered postfix emails?

in flag

I recently discovered that all emails that were meant to be being sent to a particular address of mine via postfix on my Ubuntu server have been getting rejected by the 3rd party email provider.

So there is about 6 months of emails I have not received (the emails were from a submission form on my website).

I have checked and postfix mail queue is empty.

This is a sample log entry when an email was non-delivered (xxx's for privacy).

Nov 14 21:17:51 ip-xxx-xxx-xxx-xxx postfix/smtp[2932654]: D6F393EA37: to=<[email protected]>, relay=mx2.privateemail.com[198.54.122.215]:25, delay=12, delays=0.02/0.01/7.2/5.1, dsn=5.1.8, status=bounced (host mx2.privateemail.com[198.54.122.215] said: 554 5.1.8 <[email protected]>: Sender address rejected: Domain not found (in reply to RCPT TO command))
Nov 14 21:17:51 ip-xxx-xxx-xxx-xxx postfix/cleanup[2932652]: 44F5E3EA38: message-id=<20211114211751.44F5E3EA38@ip-xxx-xxx-xxx-xxx.us-east-2.compute.internal>
Nov 14 21:17:51 ip-xxx-xxx-xxx-xxx postfix/bounce[2932655]: D6F393EA37: sender non-delivery notification: 44F5E3EA38
Nov 14 21:17:51 ip-xxx-xxx-xxx-xxx postfix/qmgr[4079]: 44F5E3EA38: from=<>, size=3166, nrcpt=1 (queue active)
Nov 14 21:17:51 ip-xxx-xxx-xxx-xxx postfix/qmgr[4079]: D6F393EA37: removed
Nov 14 21:17:51 ip-xxx-xxx-xxx-xxx postfix/local[2932656]: 44F5E3EA38: to=<[email protected]>, relay=local, delay=0.01, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Nov 14 21:17:51 ip-xxx-xxx-xxx-xxx postfix/qmgr[4079]: 44F5E3EA38: removed

Is there any way to retrieve the non-delivered emails over the last 6 months?

Paul avatar
cn flag
If I'm understanding those logs correctly, the only message delivered by Postfix is a sender non-delivery notification. Unless the sender also saved to a sent items folder some place, the only thing you should be able to discover is an inbox stuffed with those non-delivery notifications.
Score:2
za flag

In principle, if you have something in the queue, you may find a list of such mail via

postqueue -p

which tells you IDs. Then, for each ID, you may print a complete body of that email with

postcat -q <ID>

And if you decide to delete a message,

postsuper -d <ID>

However, in your case you have nothing in the queue, so nowhere you can get the mail, unless it was saved somewhere before it was given to Postfix.

Your mail was rejected with 554 code. 5xx codes mean non-recoverable error. This kind of error makes Postfix think the mail is not worth keeping, because it could not be delivered in any subsequent attempts. By the way, the "domain not found" should not be "non-recoverable" (because it could be the problem with the DNS on the receiver side), but in this case you seem to have "private" DNS name, which could justify the hard fail.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.