#1: Use MaildropHost for sending mails

Contents
  1. Definitions
  2. Motivation
  3. Proposal
  4. Implementation
  5. Risks
by radimnov last modified Jun 11, 2006 12:22 AM

MaildropHost offer asynchronous mail sending functionality, which was removed from SMH.

Proposed by
Radim Novotny
Seconded by
Christian Heimes
Proposal type
Architecture
State
being-discussed

Definitions

SMH - SecureMailHost
MDH - MailDropHost
MH - MailHost

Motivation

Asynchronous mail sending is very useful feature. It may speed-up server response when mail server does not respond immediatelly or when Plone server is sending large number of mails (for example newsletters). Async mail sending was removed from SHM itself because was too experimental. MaildropHost is intended to be used in this case.

Proposal

Modify current SMH implementation to use MaildropHost if available.

Add TTW configuration checkbox: "Use MaildropHost service" This checkbox will be available only when MDH is available, of course, set to True by default. Another option is leave this configuration in config.py only (automatically decide whether use MDH or not).

Modify Plone prefs_mailhost_form template appropriatelly (add "Use MaildropHost service" checkbox). See Risks section for details.

Suppose large Zope installation with one Zope admin and several Plone sites. Each Plone site has own Plone site manager.

Zope admin may

  1. want to use MDH everytime (not to allow Plone site admins to modify settings) or
  2. allow to modify this setings (use MDH or not) by Plone site managers

ad 1) this option must be defined in SMH/config.py by the Zope admin. We need to add this option and use it where needed.

ad 2) this option needs new checkbox in the ZMI and Plone interface - "Use MaildropHost" and Plone admin may switch using MDH on/off. If MDH is set to "on", Plone admin can't edit MDH SMTP settings TTW (MDH is using own sitewide configuration file). If MDH is set to "off", Plone site admin may change SMH settings as usual. Please see Risks section too.

Implementation

Modify current SMH implementation (do not alter existing code, add USE_MAILDROPHOST variable and do new functions only when this is set to True).

Risks

There may be problem in the Plone setup UI, because user inserts mail server, port, username and password and these values are not used (MaildropHost has own config.py module). MaildropHost does not allow TTW configuration.

Solution: we should declare new public method of SecureMailHost class (something like isMaildropHostUsed) which may be used in the prefs_mailhost_form template to inform site manager, that MaildropHost configuration is used for sending mail (and config.py for settings). We can add "Use MaildropHost service" checkbox to the Plone UI too (this will need another msgid to the translation catalog). How to hide SMH SMTP settings when users selects "Use MaildropHost service" in this case ?

Another risk may be using old MailHost as backend for e-mail generator. Proposed implementation would pass e-mail message generated by the SMH to the MDH (and MH) including all headers. MH is munging some headers. It'd be nice to have something like send_plain function in MH (to send message text including headers AS IS to SMTP server).

Comments (6)

Peter Simmons Sep 23, 2006 12:43 AM
We often used mailDrophost with plone to make sending mail more reliable (transaction safe for example)

Because of Plone's change to SecureMailHost which has a slightly different send call (message instead of messageText) and that MailDrophost extends MailHost we found we needed to make some changes.

The easy solve was to make MailDrophost extend SecureMailHost.

Just something to be aware of when implementing this proposal. Also let me know if/when this goes ahead as I would be happy to help out.
Gael Fraiteur Oct 11, 2006 09:05 AM
Simon,

I agreee with you. It is a great proposal (I've posted it to the authors of MaildropHost). Unfortunately I am not a Zope guru. Could you please be more precise and tell how to make MaildropHost extend SecureMailHost? Do you have something as a patch? If you can please send me something to gael at fraiteur dot net.

Thank you.

Gael (postsharp.org)
Gael Fraiteur Oct 11, 2006 08:27 PM
Thank you Pete for the private response.

So the answer is easy. In file MaildropHost.py, perform the following two changes:

#from Products.MailHost.MailHost import MailHost
from Products.SecureMailHost.SecureMailHost import SecureMailHost as MailHost

# def _send(self, m_from, m_to, body):
    def _send(self, m_from, m_to, body, debug=False):

And that's all!

Gael
Julian Robbins Dec 22, 2006 03:45 PM
Hi

When I switched to MDH as above and tried sending myself an email from the 'Send To' option on Plone pages, I got lots of mail formatting issues., and the email I recd had no Subject line.

I cant really use it like this. I'm using Plone 2.1.2,
Zope (Zope 2.8.6-final, python 2.3.5, linux2),
Python 2.3.5 (#2, Sep 5 2005, 15:15:54) [GCC 4.0.2 20050808 (prerelease) (Debian 4.0.1-4ubuntu6)],
PIL 1.1.5

Any ideas?

Julian

IE

From nobody Fri Dec 22 15:41:02 2006
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
To: joolsr@fastmail.fm
Subject: =?utf-8?q?Welcome_to_Q-par_Angus_Ltd?=
From: julian.robbins@q-par.com

ClRoaXMgbGluayBpcyBzZW50IHRvIHlvdSBmcm9tIGh0dHA6Ly93d3cucS1wYXIuY29tCgpZb3Ug
YXJlIHJlY2VpdmluZyB0aGlzIG1haWwgYmVjYXVzZSBzb21lb25lIHJlYWQgYSBwYWdlIGF0Ck1p
Y3Jvd2F2ZSBBbnRlbm5hcywgSG9ybiBBbnRlbm5hcywgUG9zaXRpb25lcnMsIFJlc2VhcmNoIGFu
ZCBDb25zdWx0YW5jeQphbmQgdGhvdWdodCBpdCBtaWdodCBpbnRlcmVzdCB5b3UuCgpJdCBpcyBz
ZW50IGJ5IGp1bGlhbi5yb2JiaW5zQHEtcGFyLmNvbSB3aXRoIHRoZSBmb2xsb3dpbmcgY29tbWVu
dDoKIlRoaXMgaXMgYSB0ZXN0IGxpbmsiCgpXZWxjb21lIHRvIFEtcGFyIEFuZ3VzIEx0ZAoKRXhw
ZXJ0cyBpbiBNaWNyb3dhdmUgYW5kIFJGIEVuZ2luZWVyaW5nIHdpdGggU3BlY2lhbGlzYXRpb24g
aW4gQW50ZW5uYSBTeXN0ZW1zIGFuZCBBbnRlbm5hIFBvc2l0aW9uaW5nIFN5c3RlbXMKCmh0dHA6
Ly93d3cucS1wYXIuY29tL2Zyb250LXBhZ2UtMS9jb250ZW50cGFuZWxzX3ZpZXcKCi0tCkp1bGlh
biBSb2JiaW5zCgoK
Julian Robbins Oct 31, 2006 01:43 PM
Hi

I had a lot of problems, after installing MailDropHost, with the std mail sending. After adding the lines to the config as suggested above, it works, but a GUI tool would have saved me about 3 hours or messing about in the dark. I'm not being awkward, but saying that this idea is great, and that you would have saved me a lot of time, so its definitely a great plan !!