Re: [exim] Deliver mail to another file if quota is full

Top Page
Delete this message
Reply to this message
Author: Phil Pennock
Date:  
To: Bernd Kuhls
CC: exim-users
Subject: Re: [exim] Deliver mail to another file if quota is full
On 2007-06-07 at 19:40 +0200, Bernd Kuhls wrote:
> here we have a policy not to bounce any mail.
>
> Appendfile delivery takes place to /home/${local_part}/.imap_mail/inbox
> If the user is over filesystem quota, the mail should be
> stored in /var/mail/${local_part} instead.
>
> How to achieve this?


When a mail can't be delivered because of a filesystem quota, the
delivery is deferred. It's retried according to the policies in the
retry section of the config; if you place the delivery to /home/ first
but use a condition restriction to check first_delivery and/or
$message_age, then you can ensure that the /home/ delivery is only tried
if the message is on its first delivery and/or is "young enough". Then
you have the /var/mail/ delivery Router immediately after the /home/
delivery Router with all the same restrictions except the
first_delivery/$message_age ones.

If you check section 32.5 of the Exim Spec (spec.txt), then you'll see
that you can set explicit retry policies for mails deferred for quota
reasons. You'll probably want to tune those too. Even better, you can
set different retry policies for over-quota mailboxes dependent upon how
recently the user last checked their email.

If you choose to allow a couple of attempts to deliver "normally", then
the issue to be very careful of is what happens when immediate delivery
isn't tried for some reason other than quota issues. Eg, the system
load goes high so deliveries are deferred and the load then stays high
for a while. So you also want to make sure that you _don't_ skip the
/home/ delivery unless the first_delivery condition is false.

So to only try delivery to /home/${local_part}/.imap_mail/inbox once,
use:
condition = ${if first_delivery}

To try delivery there more than once, something like:

condition = ${if or{{first_delivery}{<={$message_age}{600}}}}

which allows retries for up to 10 minutes, or even longer provided that
this is the first delivery attempt. This would need some rather rapid
retrying to be useful.

-Phil