November 3rd, 2004, 03:06 PM
Problem with py2exe and email.MIMEText
I ended up just simplifying the email method and ignoring the email.MIMEText option.
Since I was only sending a simple text smtp message, I ended up just using smtplib:
to = toaddr
fromaddr = "firstname.lastname@example.org"
body = "blah message body"
subj = "Subject: Network Error on blah \n"
mail = smtplib.SMTP('mailserver')
mail.sendmail(fromaddr, to , subj + body)
Hey all--hope someone has seen this issue before.
I have a small app I am writing, and one section is causing me grief.
In the app, I am sending an email via an external smtp relay using code like this:
body = ("blah blah blah")
msg['Subject'] = "Network issue"
msg['From'] = fromaddr
msg['To'] = to
All works fine if I am on either win32 or linux with Python installed.
The problem starts when I use py2exe to create an exe for systems without Python installed.
I am getting an error on win32 systems:
File "email\Encoders.pyc", line 85, in encode_7or8bit
LookupError: unknown encoding: ascii
This section of the module, sets the Content Type Encoding for the message to 'ascii' if it is 7bit.
It is my understanding that the email.MIMEText _encoders option is deprecated, and just relies on the _charset setting.
I am assuming this is an issue with py2exe , but was wondering if anyone else had run into this problem.
The obvious answer is to just install python on the win32 boxes, but this is not an option for me.
Any ideas would definitely be appreciated, if not--thanks for looking.