I am using pipe over SSH to deliver some e-mails for special processing to another server, what I have configured in master.cf.
foobar unix - n n - - pipe
flags=RF user=foobar:foobar argv=/usr/bin/ssh -T foobar@foobar /usr/local/bin/foobar ${recipient}
The problem I am having is that if this server is not available (or for some other reason SSH connection fails) whole delivery fails and sender receives message about that. What I would like is that if it fails that e-mail is put back into the queue for later retry. And only if for few days this delivery is not made that sender is notified about that. How can I configure Postfix in this way?
Add
-o soft_bounce=yes
to the definition inmaster.cf
.Example:
This will keep mail in the deferred queue forever (or until the machine comes back to life and postfix retries it), and will not bounce after a few days, but it's the best I could find (and even that was quite well hidden).
If the command that
pipe
is delivering to returns an exit code of 75, then that causes the delivery to be deferred rather than bounced. Alternatively, if the first line of output appears to have an extended SMTP status (e.g. "4.2.0") that takes priority.I would wrap up the ssh command in a shell script or something that detects a failure and converts that to the right output/exit status.
This allows the delivery program to flag messages as undeliverable as opposed to always having them retried. And keeps the
soft_bounce
option as a debugging safety net.(I appreciate you already have an answer, but thought this might be useful as an alternative for anyone else finding this question)