MIMEText encode error - Python 2.6.6

N

neubyr

I am trying to write a program which can email file's content using
smtplib. I am getting following error while using Python 2.6.6
version.

{{{
File "./killed_jobs.py", line 88, in sendmail
msg = MIMEText(ipfile.read, 'plain')
File "/home/ssp/sge/python/2.6.6/lib/python2.6/email/mime/text.py",
line 30, in __init__
self.set_payload(_text, _charset)
File "/home/ssp/sge/python/2.6.6/lib/python2.6/email/message.py",
line 224, in set_payload
self.set_charset(charset)
File "/home/ssp/sge/python/2.6.6/lib/python2.6/email/message.py",
line 266, in set_charset
cte(self)
File "/home/ssp/sge/python/2.6.6/lib/python2.6/email/encoders.py",
line 73, in encode_7or8bit
orig.encode('ascii')
AttributeError: 'builtin_function_or_method' object has no attribute 'encode'

}}}


I am referring to email examples on the doc site
http://docs.python.org/release/2.6.6/library/email-examples.html#email-examples
.. Following is the msg object part in my code:

{{{
....
....
def sendmail(inputfile):
ipfile = open(inputfile, 'r')
msg = MIMEText(ipfile.read, 'plain')
ipfile.close()

....
....
}}}

I have tried setting subtype and chartype separately as mentioned here
- http://docs.python.org/release/2.6.6/library/email.mime.html, but
the error remains same. Any help on what might be wrong here?

thanks,
neuby.r
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top