-1

Sometimes my users accidentally delete their .forward files, and then Postfix falls back to delivering mails to /var/spool/mail. I would like it to instead put the message in the Hold or Deferred queue so that I can notice the situation and help the user fix their .forward file. Is this possible?

4
  • 1
    Rather than relying on the presence of a .forward file, why don't you (re-) configure Postfix so that mail gets delivered correctly by default?
    – HBruijn
    Mar 29, 2016 at 9:32
  • @HBrujin We are providing shell accounts to users and want them to be able to easily change where their mails are going by themselves. This seemed like the easiest way to accomplish that (and it also work with our current systems).
    – petergil
    Mar 29, 2016 at 12:25
  • I thought that maybe you relied on a .forward file to for instance ensure a Maildir/ format, but regardless: normally the presence of a .forward is an exception rather than the default and the absence of such a file should result in correct delivery. - SMTP standards are such that anything that results in delivery errors, such as an incorrectly formatted .forward, should return a delivery failure to the original sender. - In short I don't think you can arbitrarily put the mail on hold.
    – HBruijn
    Mar 29, 2016 at 13:04
  • Well, for our users the only documented way to receive mail is by having a .forward file, so it hopefully it isn't an exception here. Also, in Postfix there is literally a transport named defer, which I thought would work, but it turns out it didn't. Anyway I found out an alternative (and a bit hacky) way to solve it.
    – petergil
    Mar 29, 2016 at 16:40

1 Answer 1

0

So I couldn't find any obvious way to do it. In theory I think that it should be possible to use a transport to get it to work but I didn't manage to have it actually hold or defer the mails.

The way I solved it (which is very hacky) is to use the mailbox_command variable in the main.cf file. It is intended to specify an external command to use instead of mailbox delivery. As it turns out it also listens smtp status codes, which can be be used to force the mail to be held on the server. First, add the following line in main.cf:

mailbox_command = /etc/postfix/defer-mail

And create the file /etc/postfix/defer-mail and have it look something like this:

#!/bin/bash

echo "4.3.0 Mail expansion not available (missing .forward file)"

exit 1

This will put mails in your deferred queue, from which it is then possible to move into the hold queue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .