Mailing List Archive

How to defer (ie deliberately delay) delivery
Greetings,

We are using Exim as a MTA to handle mails from applications (eg cron
jobs), with all mail directed via a smarthost (so exim doesn't connect
directly to the internet).

A user has requested a feature whereby he can *delay* the delivery of
a mail until a fixed time (eg 22.00h). The idea is that the mail is
generated asynchronously during the day and submitted immediately to
exim, but with a header like "Deliver-At: 22.00". The mail should then
sit in the queue until the first queue-run after 22.00h. Then we
should detect it and send it to the smart-host for final delivery.

I have checked the documentation and the mailing-list archives, but
can't see anything that looks like it might do this. Any
suggestions/pointers?

Best regards,
Owen Boyle

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to defer (ie deliberately delay) delivery [ In reply to ]
On Tue, 23 Oct 2007 08:49:31 -0500, owen@boyle.ch wrote:
>A user has requested a feature whereby he can *delay* the delivery of
>a mail until a fixed time (eg 22.00h). The idea is that the mail is
>generated asynchronously during the day and submitted immediately to
>exim, but with a header like "Deliver-At: 22.00". The mail should then
>sit in the queue until the first queue-run after 22.00h. Then we
>should detect it and send it to the smart-host for final delivery.

First, modify your smarthost router to decline mails that have a
"Deliver-At:" header. Then, write a second smarthost router that will
defer messages until the time specified in the Deliver-At: header has
passed.

Greetings
Marc

--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Mannheim, Germany | Beginning of Wisdom " | http://www.zugschlus.de/
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fon: *49 621 72739834

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to defer (ie deliberately delay) delivery [ In reply to ]
Quoting Marc Haber <mh+exim-users@zugschlus.de>:

> On Tue, 23 Oct 2007 08:49:31 -0500, owen@boyle.ch wrote:
>> A user has requested a feature whereby he can *delay* the delivery of
>> a mail until a fixed time (eg 22.00h). The idea is that the mail is
>> generated asynchronously during the day and submitted immediately to
>> exim, but with a header like "Deliver-At: 22.00". The mail should then
>> sit in the queue until the first queue-run after 22.00h. Then we
>> should detect it and send it to the smart-host for final delivery.
>
> First, modify your smarthost router to decline mails that have a
> "Deliver-At:" header. Then, write a second smarthost router that will
> defer messages until the time specified in the Deliver-At: header has
> passed.

Many thanks to Chris and Marc for helpful insights. I am working on a
solution and will post it back later for posterity :-)

Rgds,
Owen

>
> Greetings
> Marc
>
> --
> -------------------------------------- !! No courtesy copies, please !! -----
> Marc Haber | " Questions are the | Mailadresse im Header
> Mannheim, Germany | Beginning of Wisdom " | http://www.zugschlus.de/
> Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fon: *49 621 72739834
>
> --
> ## List details at http://lists.exim.org/mailman/listinfo/exim-users
> ## Exim details at http://www.exim.org/
> ## Please use the Wiki with this list - http://wiki.exim.org/
>



--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to defer (ie deliberately delay) delivery [ In reply to ]
For the record, the solution I came up with was as follows:

# This router checks mails for a "Delivery-Age" header. If it exists
# and the actual message age is less than that specified in the
# header, mails are deferred until the next queue run, when they are
# tested again. When the condition is finally met, mails pass through
# to the smarthost router.
delay_until_delivery_age:
driver = redirect
domains = ! +local_domains
condition = ${if < {$message_age}{$header_delivery-age:}{yes}{no}}
allow_defer
data = :defer: Age now: $message_age Deliver at: $header_delivery-age:
no_verify

# All mails are routed to the Corporate mail-server for final delivery
smarthost:
driver = manualroute
domains = ! +local_domains
transport = remote_smtp
route_list = * 192.168.1.1 bydns
errors_to = $header_sender

Thanks again to the list and the Wiki
(http://wiki.exim.org/FAQ/Configuration_cookbook/Q9807)

Rgds,
Owen Boyle


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to defer (ie deliberately delay) delivery [ In reply to ]
On Oct 30, 2007 8:23 PM, <owen@boyle.ch> wrote:
> For the record, the solution I came up with was as follows:
>
> # This router checks mails for a "Delivery-Age" header. If it exists
> # and the actual message age is less than that specified in the
> # header, mails are deferred until the next queue run, when they are
> # tested again. When the condition is finally met, mails pass through
> # to the smarthost router.
> delay_until_delivery_age:
> driver = redirect
> domains = ! +local_domains
> condition = ${if < {$message_age}{$header_delivery-age:}{yes}{no}}
> allow_defer
> data = :defer: Age now: $message_age Deliver at: $header_delivery-age:
> no_verify
>
> # All mails are routed to the Corporate mail-server for final delivery
> smarthost:
> driver = manualroute
> domains = ! +local_domains
> transport = remote_smtp
> route_list = * 192.168.1.1 bydns
> errors_to = $header_sender
>
> Thanks again to the list and the Wiki
> (http://wiki.exim.org/FAQ/Configuration_cookbook/Q9807)
>
> Rgds,
>
> Owen Boyle
>
>
> --
> ## List details at http://lists.exim.org/mailman/listinfo/exim-users
> ## Exim details at http://www.exim.org/
> ## Please use the Wiki with this list - http://wiki.exim.org/
>

Hello Owen,

Having relied on
(http://wiki.exim.org/FAQ/Configuration_cookbook/Q9807 as the
reference, did you end up setting up a suitable retry rule as
recommended or does it just work automagically when the first queue
run is fired?
I intend to use the following modification to delay messages from some
users for 10 minutes:

delay_outgoing:
driver = redirect
domains = !+local_domains : !+relay_to_domains
senders = ! : lsearch;/usr/local/etc/exim/delayed_senders
condition = ${if < {$message_age}{360}{yes}{no}}
allow_defer
data = :defer: message not old enough
no_verify

I have been asked to implement this to allow my bosses to recall mail
(i.e. ask me to delete it from the queue to stop it from being sent if
they change their mind after hitting "Send/Receive" in Outlook:-)

In my situation, since Exim runs with "-bd -q30m", I am thinking I
need to craft a special retry rule. However, I must admit I am not
sure what form the rule should take, but I do believe that running
Exim with "-bd -q15m" perhaps eliminates the need for crafting a
special retry rule.

Hi list members , please advise.


--
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254733744121/+254722743223
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

"Oh My God! They killed init! You Bastards!"
--from a /. post

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to defer (ie deliberately delay) delivery [ In reply to ]
Odhiambo Washington wrote:
> On Oct 30, 2007 8:23 PM, <owen@boyle.ch> wrote:
>> For the record, the solution I came up with was as follows:
[snip]
> Having relied on
> (http://wiki.exim.org/FAQ/Configuration_cookbook/Q9807 as the
[snip]
> In my situation, since Exim runs with "-bd -q30m", I am thinking I
> need to craft a special retry rule. However, I must admit I am not
> sure what form the rule should take, but I do believe that running
> Exim with "-bd -q15m" perhaps eliminates the need for crafting a
> special retry rule.

Have you considered doing something insane like using the "queue_only"
control and then simply not running a queue runner? Instead use a script
that is run once a minute to scan the exim mail queue (exim -bp) and
only deliver messages (exim -M <message-id>) if they're over 10m old?
So long you don't have a huge mail queue it might work. Never tried it,
but it might give you that 10m buffer or whatever buffer you want
without having to deal with retry rules.
It has some issues .. you would have to implement your own retry db for
all the message that didn't make it on the first queue run to stop it
from trying to send the message every minute thereafter :P Hmm... maybe
retry rules are the way to go there too as exim wont actually attempt a
delivery after the first one until it's up for a real retry as per the
rules.
I really shouldn't post first thing in the morning .. too many weird ideas.

Ted

--
The Exim Manual
http://www.exim.org/docs.html
http://www.exim.org/exim-html-current/doc/html/spec_html/index.html

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to defer (ie deliberately delay) delivery [ In reply to ]
On Nov 13, 2007 1:08 AM, Ted Cooper <eximX1211@linuxwan.net> wrote:
> Odhiambo Washington wrote:
> > On Oct 30, 2007 8:23 PM, <owen@boyle.ch> wrote:
> >> For the record, the solution I came up with was as follows:
> [snip]
> > Having relied on
> > (http://wiki.exim.org/FAQ/Configuration_cookbook/Q9807 as the
> [snip]
> > In my situation, since Exim runs with "-bd -q30m", I am thinking I
> > need to craft a special retry rule. However, I must admit I am not
> > sure what form the rule should take, but I do believe that running
> > Exim with "-bd -q15m" perhaps eliminates the need for crafting a
> > special retry rule.
>
> Have you considered doing something insane like using the "queue_only"
> control and then simply not running a queue runner? Instead use a script
> that is run once a minute to scan the exim mail queue (exim -bp) and
> only deliver messages (exim -M <message-id>) if they're over 10m old?
> So long you don't have a huge mail queue it might work. Never tried it,
> but it might give you that 10m buffer or whatever buffer you want
> without having to deal with retry rules.
> It has some issues .. you would have to implement your own retry db for
> all the message that didn't make it on the first queue run to stop it
> from trying to send the message every minute thereafter :P Hmm... maybe
> retry rules are the way to go there too as exim wont actually attempt a
> delivery after the first one until it's up for a real retry as per the
> rules.
> I really shouldn't post first thing in the morning .. too many weird ideas.
>
> Ted


Yes, you really should have given this a good thought first:-)


--
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254733744121/+254722743223
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

"Oh My God! They killed init! You Bastards!"
--from a /. post

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/