Re: help with sending mail in Program

Discussion in 'Python' started by Ivan Shevanski, Jun 16, 2005.

  1. 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" <>'
    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/
     
    Ivan Shevanski, Jun 16, 2005
    #1
    1. Advertising

  2. On Wed, 15 Jun 2005 22:04:18 -0400, "Ivan Shevanski"
    <> declaimed the following in comp.lang.python:


    > body = 'x is',x,'y is',y,'.Lets hope that works!'


    Did you print body? The above is a tuple of five items, a
    string, whatever x is, a string, whatever y is, and a string.

    Try something like:

    body = "x is %s\ny is %s\nLets hope that works!" % (x, y)

    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
     
    Dennis Lee Bieber, Jun 16, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    55,490
  2. Ivan Shevanski

    help with sending mail in Program

    Ivan Shevanski, Jun 6, 2005, in forum: Python
    Replies:
    2
    Views:
    287
    Fuzzyman
    Jun 7, 2005
  3. Ivan Shevanski

    Re: help with sending mail in Program

    Ivan Shevanski, Jun 7, 2005, in forum: Python
    Replies:
    5
    Views:
    310
    Kent Johnson
    Jun 9, 2005
  4. Replies:
    0
    Views:
    1,377
  5. Luke
    Replies:
    2
    Views:
    4,729
    Nigel Wade
    Mar 15, 2007
Loading...

Share This Page