[Tutor] smtp error

Shitiz Bansal shitizb at yahoo.com
Wed Sep 7 04:25:50 CEST 2005


does this error make sense to anyone?

Traceback (most recent call last):
  File "C:/Documents and
Settings/Administrator/Desktop/lkp.py", line 46, in
-toplevel-
    s.sendmail(msg['From'], i, msg.as_string())
  File "C:\Python24\lib\smtplib.py", line 692, in
sendmail
    raise SMTPDataError(code, resp)
SMTPDataError: (550, 'Invalid recipient:
shitizb at yahoo.com')



heres the complete code:
# Import smtplib for the actual sending function
import smtplib

# Here are the email pacakge modules we'll need
import base64
import cStringIO
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
COMMASPACE = ', '
import email
# Create the container (outer) email message.
msg = MIMEMultipart()
msg['Subject']=raw_input("Subject:") 
# me == the sender's email address
# family = the list of all recipients' email addresses
msg['From'] =raw_input("From:")
kk = raw_input("To filename:")
# Guarantees the message ends in a newline
msg.epilogue = ''
file1=raw_input("text measage file:")
fp = open(file1, 'rb')
img = MIMEText(fp.read())
fp.close()
msg.attach(img)
file=raw_input("File to attach:")
fp = open(file, 'rb')
contentType="application/octet-stream"
contentsEncoded=cStringIO.StringIO()
mainType=contentType[:contentType.find("/")]
cte="base64"
base64.encode(fp,contentsEncoded)
subMsg=email.Message.Message()
subMsg.add_header("Content-transfer-encoding",cte)
subMsg.set_payload(contentsEncoded.getvalue())
contentsEncoded.close()

fp.close()
msg.attach(subMsg)
fp=open(kk,'r')
# Send the email via our own SMTP server.
mailadds=fp.readlines()
for i in mailadds:
    msg['To']=i
    s = smtplib.SMTP()
    s.connect()
    s.sendmail(msg['From'], i, msg.as_string())
    s.close()




	
		
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/


More information about the Tutor mailing list