Score:0

How to export on a text file the content of all mails in queue?

cn flag

I'm noticing an anomalous activity for postfix and I want to check the outgoing mails

mailq shows a bunch of mails in queue with their id without any info on their specific body content to give me a clear idea of what is generating these outgoing mails

also

postcat -q id

it's useless because the suspicious mails and related ids are continuously processed and removed from queue, so when I perform the check on some id, it is no longer valid.

How could I export on a text file the content of all mails in queue?

Score:0
us flag

Following script will help you to store all the mail contents to a file named "mail_contents.txt"

#!/bin/bash
for id in $(postqueue -p | awk '$7 ~/@/ { print $1 }' | awk -F "*" '{print $1}'); do postcat -q $id; done > mail_contents.txt
cn flag
it seems `postcat -q` it does nothing without an id passed
Zareh Kasparian avatar
us flag
@AndreaF sorry, you are correct. i have edited my answer and provided you with bash script. please check and let me know the result.
cn flag
thanks for reply, but this is similar to one of my attemts, seems this method fails at first id that is no longer valid(ids are continuously processed and removed as I have said), it is needed a way to export them in bulk regardlesss the id (maybe some way to export them directly from the file used to temporary store them??)
I sit in a Tesla and translated this thread with Ai:

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.