I was going to say "you can't", but apparently you can. mailx
, which is what's installed as the mail
command on most modern UNICES, says in the man page that you can set a variable:
Normally, mailx invokes sendmail(8) directly to transfer messages.
If the smtp variable is set, a SMTP connection to the server specified
by the value of this variable is used instead. If the SMTP server
does not use the standard port, a value of server:port can be given,
with port as a name or as a number.
Check the man
page for your mail command on how to set this.
The pipeline can be analyzed step by step to see what it does. Try running each command in sequence until you understand them all:
postqueue -p
print the queue
postqueue -p | tail -n +2
get rid of the first couple lines
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / spammer@example\.net/ { print $1 }'
search for any lines with spammer@example.net; print the first field of those lines.
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / spammer@example\.net/ { print $1 }' | tr -d '*!'
get rid of any *!
This will output a bunch of queue ids.
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / spammer@example\.net/ { print $1 }' | tr -d '*!' | postsuper -d -
The final command tells postfix to delete those queue ids.
Read The Fine Man pages on postqueue
, tail
, tr
, and postsuper
. Awk is a more complicated, it's its own little language. you'll need a bit more than a man page to understand its complexity, although in my experience 99% of the awk usage is much like that particular one-liner.
Best Answer
What you want is getmail.
http://pyropus.ca/software/getmail/
You want the
delete_after (integer)
attribute: