Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; 'attribute': 0.07; 'python': 0.08; 'skip:" 60': 0.09; 'subject:error': 0.10; 'examples': 0.11; 'def': 0.15; "'r')": 0.16; '__init__': 0.16; 'sendmail': 0.16; 'subtype': 0.16; 'received:74.125.82.44': 0.17; 'received:mail-ww0-f44.google.com': 0.17; 'thanks,': 0.18; 'trying': 0.21; 'here?': 0.23; 'referring': 0.23; 'tried': 0.26; 'version.': 0.29; 'message- id:@mail.gmail.com': 0.29; 'remains': 0.30; 'separately': 0.30; 'url:library': 0.31; 'error': 0.32; 'to:addr:python-list': 0.33; 'setting': 0.34; 'doc': 0.34; 'object': 0.35; 'file': 0.36; 'url:python': 0.36; 'skip:" 10': 0.36; 'using': 0.37; 'but': 0.37; 'received:74.125.82': 0.38; 'received:google.com': 0.38; 'url:org': 0.38; 'skip:o 20': 0.38; 'getting': 0.39; 'url:docs': 0.39; 'help': 0.39; 'to:addr:python.org': 0.39; 'received:74.125': 0.39; 'might': 0.40; 'here': 0.65; '30,': 0.74; 'url:email': 0.74; '{{{': 0.84; '}}}': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=moM6NmOqYz1vyI7ekV3ukFwK7x+ej2akyEmddfat1kc=; b=vDg/gTMzX/rKHseEUnVw1yaHa2yvvuVC+PKjsbxXXUrlb29wLECu2DHrnqPV7SyfLI wNV2WCxKNXtQq+iawuiWp8G5XXEwA4yylpEh3RLfrn3mzt/a3//cr4DCPbcLR5Y156fa F87xpy95FZXs1/4owfbYrHac5lK3S4anXsK2U= MIME-Version: 1.0 Date: Tue, 6 Sep 2011 16:52:52 -0500 Subject: MIMEText encode error - Python 2.6.6 From: neubyr To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315345979 news.xs4all.nl 2554 [2001:888:2000:d::a6]:46498 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12855 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