Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: help with sending mail in Program

Thread Tools

Re: help with sending mail in Program

Ivan Shevanski
Posts: n/a
Well everything was working in this mail sending script until. . .this:

Traceback (most recent call last):
File "", line 27, in ?
sendToMe(subject, body)
File "", line 8, in sendToMe
send(me, me, subject, body)
File "", line 16, in send
msg = MIMEText(body)
File "C:\Python24\lib\email\", line 28, in __init__
self.set_payload(_text, _charset)
File "C:\Python24\lib\email\", line 218, in set_payload
File "C:\Python24\lib\email\", line 256, in set_charset
File "C:\Python24\lib\email\", line 63, in encode_7or8bit
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" <(E-Mail Removed)>'
send(me, me, subject, body)

def send(frm, to, subject, body):
s = SMTP()
# s.ehlo('')

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

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

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?


__________________________________________________ _______________
Donít just search. Find. Check out the new MSN Search!

Reply With Quote
Dennis Lee Bieber
Posts: n/a
On Wed, 15 Jun 2005 22:04:18 -0400, "Ivan Shevanski"
<(E-Mail Removed)> 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)

> ================================================== ============ <
> Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <> <
> Overflow Page: <> <

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Failure Sending Mail" when using System.Net.Mail and ASP.Net 2.0 ASP .Net 4 09-28-2007 03:57 PM
problem sending mail: Sending the email to the following server failed Luke Java 2 03-15-2007 10:54 AM
pls help me when i sent mail, it vil sending twice instead of once ,am using java.mail,am sending my code.... Java 0 09-28-2006 06:38 AM
Re: help with sending mail in Program Ivan Shevanski Python 5 06-09-2005 12:33 PM
help with sending mail in Program Ivan Shevanski Python 2 06-07-2005 08:02 AM