Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12855
| Date | 2011-09-06 16:52 -0500 |
|---|---|
| Subject | MIMEText encode error - Python 2.6.6 |
| From | neubyr <neubyr@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.813.1315345979.27778.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
MIMEText encode error - Python 2.6.6 neubyr <neubyr@gmail.com> - 2011-09-06 16:52 -0500
csiph-web