[email/quoprimime.py] AttributeError: 'tuple' object has no attribute 'lstrip'

Chris Rebert clp at rebertia.com
Mon Jan 5 08:24:16 CET 2009


On Sun, Jan 4, 2009 at 11:15 PM, Gilles Ganault <nospam at nospam.com> wrote:
> Hello
>
>        I successfully use the email package to send e-mail from Python
> scripts, but this script fails when I fetch addresses from an SQLite
> database where data is Unicode-encoded:
>
> ======
> from email.MIMEText import MIMEText
> import smtplib,sys
> import apsw
>
> connection=apsw.Connection("test.sqlite")
> cursor=connection.cursor()
>
> subject = "My subject"
> f = open("message.txt", "r")
> message = f.read()
> f.close()
>
> msg = MIMEText(message)
>
> msg['Subject'] = subject
> >From = "me at acme.com"
> msg['From'] = From
>
> server = smtplib.SMTP("smtp.acme.com")
>
> sql="SELECT email FROM people WHERE email IS NOT NULL"
> rows=list(cursor.execute(sql))
> for email in rows:
>        To = email
>        msg['To'] = email
>
>        #print To
>        #(u'dummy at acme.com',)
>
>        #AttributeError: 'tuple' object has no attribute 'lstrip'
>        #server.sendmail(From,[To],msg.as_string())
>
> server.quit
>
> connection.close(True)
> ======
>
> Does someone know what is wrong with the above? Does email choke on
> Unicode?

Please include the full Traceback so that you can be helped more easily.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list