help with sending mail in Program

Ivan Shevanski darkpaladin79 at hotmail.com
Wed Jun 15 22:04:18 EDT 2005


Well everything was working in this mail sending script until. . .this:

Traceback (most recent call last):
  File "mailvar.py", line 27, in ?
    sendToMe(subject, body)
  File "mailvar.py", line 8, in sendToMe
    send(me, me, subject, body)
  File "mailvar.py", line 16, in send
    msg = MIMEText(body)
  File "C:\Python24\lib\email\MIMEText.py", line 28, in __init__
    self.set_payload(_text, _charset)
  File "C:\Python24\lib\email\Message.py", line 218, in set_payload
    self.set_charset(charset)
  File "C:\Python24\lib\email\Message.py", line 256, in set_charset
    cte(self)
  File "C:\Python24\lib\email\Encoders.py", line 63, in encode_7or8bit
    orig.encode('ascii')
AttributeError: 'tuple' object has no attribute 'encode'

heres my code(just made to test using the variables):

from email.MIMEText import MIMEText
from smtplib import SMTP
x = 'python'
y = 'python2'

def sendToMe(subject, body):
   me = '"Ivan Shevanski" <mcskittles117 at yahoo.com>'
   send(me, me, subject, body)

def send(frm, to, subject, body):
   s = SMTP()
   s.set_debuglevel(1)
   s.connect('D421LN41')
#   s.ehlo('69.137.27.32')

   msg = MIMEText(body)
   msg['To'] = to
   msg['Subject'] = subject
   msg['From'] = frm

   s.sendmail(frm2, [to2], msg.as_string())
   s.quit()

if __name__ == '__main__':
   body = 'x is',x,'y is',y,'.Lets hope that works!'
   subject = 'Python3'
   sendToMe(subject, body)

I really have no idea whats going on. . .help?

-Ivan

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/




More information about the Python-list mailing list