[Zope] MailHost and 2.6.0

Tony McDonald tony.mcdonald@ncl.ac.uk
Tue, 22 Oct 2002 16:47:46 +0100


Hi all,
The excellent way of sending email via python outlined at
http://www.zopelabs.com/cookbook/991178206 (reproduced here for
completeness)

try:
    mailhost=getattr(context, context.superValues('Mail Host')[0].id)
except:
    raise AttributeError, "cant find a Mail Host object"

mMsg = 'a testful email message \n that contains a few line breaks. \n
~runyaga'
mTo = 'runyaga@abc.com'
mFrom = 'runyaga@xyz.com'
mSubj = 'mail subject'

mailhost.send(mMsg, mTo, mFrom, mSubj)

Doesn't work on 2.6.0. You get the following traceback;

<!--
<p>Traceback (innermost last):
<ul>

<li>  Module ZPublisher.Publish, line 98, in publish</li>

<li>  Module ZPublisher.mapply, line 88, in mapply</li>

<li>  Module ZPublisher.Publish, line 39, in call_object</li>

<li>  Module Shared.DC.Scripts.Bindings, line 252, in __call__</li>

<li>  Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec</li>

<li>  Module Products.PythonScripts.PythonScript, line 315, in _exec</li>

<li>  Module Script (Python), line 11, in xx<br />
<b>&lt;PythonScript at /NEW_cmc/cmc_tools/xx&gt;</b><br />
<b>Line 11</b></li>

<li>  Module Products.MailHost.MailHost, line 125, in send</li>

</ul>TypeError: _send() takes exactly 3 arguments (4 given)
</p>
-->

Looking at line 125 of MailHost.py you get this...
        self._send(mfrom, mto, messageText)

Whereas on the 2.5.1 version you get this (after much header manipulations),
        self._send( headers, messageText )


The interface to 'send' hasn't changed though,
    def send(self, messageText, mto=None, mfrom=None, subject=None,
             encode=None):

We are (were) using this a lot, sending a large quantity of email using
Maildrop Host and some python scripts. Now, these scripts don't work.

Can anyone shed some light on this?

Many thanks
Tone.
Ps Lest people think I'm all over 2.6.0 - I really like the 'error_log'
feature at the top level. It's very handy for debugging stuff remotely (ie
when someone calls up and says 'I have a Zope Error', you can get straight
to the traceback without needing to train them in HTML, 'View Source' and
the like...
-- 
Dr Tony McDonald,  Assistant Director, FMCC, http://www.fmcc.org.uk/
The Medical School, Newcastle University Tel: +44 191 243 6140
A Zope list for UK HE/FE  http://www.fmcc.org.uk/mailman/listinfo/zope