"MIMEMultipart instance has no attribute 'lstrip'" #1

WouterVH opened this Issue Dec 16, 2011 · 12 comments

5 participants

Plone Collective member

When testing the current trunk (2011-12-16), I'm not able to send newsletters:

2011-12-16 23:51:03 INFO Products.EasyNewsletter Sending newsletter to "testuser@gmail.com" failed, with error "MIMEMultipart instance has no attribute 'lstrip'"!

I think this was not happening wiht release 2.6.


And the full traceback?

Plone Collective member

Actually there is no traceback, it's caught in a try-except,

see https://github.com/collective/Products.EasyNewsletter/blob/master/Products/EasyNewsletter/content/ENLIssue.py#L373

    log.info("Send newsletter to \"%s\"" % receiver['email'])
    send_counter += 1
except Exception, e:
    log.info("Sending newsletter to \"%s\" failed, with error \"%s\"!" % (receiver['email'], e))
    send_error_counter += 1

correct logging (as above) is written to the log, but in the plone-site, the flas-message says the newsletter was send
because of

def send_issue(self):
    putils.addPortalMessage(_("The issue has been send."))

Hi, Since we switched to the trunk we are also experiencing the same error, In the previous version we had no problems.

Plone Collective member

I'm unable to reproduce the error with the buildout.cfg included in the ENL repo. Please provide more information about how to reproduce the bug. I refactored the method that composes the email for ENL, so there is a good possibility that something is broken since version 2.6. If you could provide a failing test for your bug, that would even be better.

Plone Collective member

Error occurs on Plone 3.3.5, therefore with Python2.4.x

Plone Collective member

Could you try to pdb into the code block to figure out what exactly goes wrong there? Or maybe even write a test that fails with Plone 3.3.x? I added a test-plone-3.3.x.cfg buildout to the repo, so you can run all tests on Plone 3.3.x.

Plone Collective member

The error is triggered in Products.MailHost:

-> mfile=StringIO(messageText.lstrip())
(Pdb) l
191 def _mungeHeaders( messageText, mto=None, mfrom=None, subject=None):
192 """Sets missing message headers, and deletes Bcc.
193 returns fixed message, fixed mto and fixed mfrom"""
194 import pdb;pdb.set_trace()
195 -> mfile=StringIO(messageText.lstrip())
196 mo=rfc822.Message(mfile)
198 # Parameters given will always override headers in the messageText.
199 # This is so that you can't override or add to subscribers by adding them to
200 # the message text.
(Pdb) messageText

(Pdb) messageText.lstrip()
*** AttributeError: MIMEMultipart instance has no attribute 'lstrip'

In Plone3.3.5 Products.MailHost is part of Zope is 2.10.x

In Plone 4.0 Products.MailHost is part of Zope 2.12.x

In Plone 4.1 uses Zope 2.13.x and Products.MailHost is a separate egg

the call to lstrip() is removed from the Mailhost-code in large commit r100406 by Alecm "Merge MailHost changes from trunk (r102756:102819)" (commit to zope-repository)

Plone Collective member

Running the test on Plone3.3.5, gives error, see

Plone Collective member

the code was taken from collective.singing.
but there the message is wrapped in collective.singing.message.Message.

I fixed is for the moment catching the error, and sending the message again as string.

Plone Collective member

It seems this fix does not send the images correctly.
So I'm in favor of reverting to the situation before using the singing-code.

Plone Collective member

Ok, go ahead. I will create a fork where I will basically remove large parts of ENL to make it work for me.

Plone Collective member
@jensens jensens closed this May 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment