"Philippe C. Martin" <[EMAIL PROTECTED]> writes: > Hi, > > I am testing the smtp module and have the following question: > > in the code below (taken from net sample) prior to adding the "Subject:" > field, the email client found the "From" and the "To". Without the > "Subject:" field on I get this: > > Email client = Evolution: the "From" field is blank > Email client = KMail: the "To" field is blank > > Any clue ? > > Thanks and regards, > > Philippe > ********************** > > import smtplib > > def prompt(prompt): > return raw_input(prompt).strip() > > > fromaddr = prompt("From: ") > toaddrs = prompt("To: ").split() > print "Enter message, end with ^D (Unix) or ^Z (Windows):" > > # Add the From: and To: headers at the start! > msg = ("From: %s\r\nTo: %s\r\n\r\n" % (fromaddr, ", ".join(toaddrs))) > while 1: > try: > line = raw_input() > except EOFError: > break > if not line: > break > msg = msg + line > > print "Message length is " + repr(len(msg)) > > server = smtplib.SMTP('smtp.sbcglobal.yahoo.com') > server.set_debuglevel(1) > server.login ('xxxxx','yyyyyyy') > server.sendmail(fromaddr, toaddrs, 'Subject:from python\n\n'+msg)
You've got \n\n after the Subject line, not \r\n. That is being treated as two newlines, thus ending the headers. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list