[Zope-dev] dtml-sendmail and transactions: Request For Comments

Phillip J. Eby pje@telecommunity.com
Sat, 11 Aug 2001 12:29:32 -0500


At 10:43 PM 8/10/01 +0200, Dieter Maurer wrote:
>Good, but isn't it difficult to make mail sending transactional:
>
>     The sending may raise exceptions.
>
>     Zope is very angry to get exceptions during the second
>     phase of the two-phase commit.
>
>     This means, sending must go into the first phase.
>     But in this case, they are sent even if a different
>     transaction manager rejects the "commit" request
>     (or raises an exception).

The way Ty and I handle this in our applications is to not use the sendmail 
tag, but instead write a file to a queue directory, where it is then sent 
by another process which monitors the queue.  This is easier to make 
transactional, since the commit operation only has to move the file to 
commit it.

Unfortunately, this is not a general solution for Zope, since it then 
requires the existence of that other process.  But in theory one could 
create a Product that would implement a daemonic thread for sending queued 
mail in this fashion.