Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Re: help with sending mail in Program

 
 
Ivan Shevanski
Guest
Posts: n/a
 
      06-16-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" <(E-Mail Removed)>'
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/o...ave/direct/01/

 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      06-16-2005
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)

--
> ================================================== ============ <
> http://www.velocityreviews.com/forums/(E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <

 
Reply With Quote
 
 
 
Reply

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 HoustonComputerGuy@gmail.com 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.... shailajabtech@gmail.com 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



Advertisments