import smtplib
fromaddr="satyenarayena.iton@gmail.com"
toaddr="satyenarayena@gmail.com"
message = 'Subject: {}\n\n{}'.format("imp", "testing file")
password="Satyenarayena@8"
server=smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(fromaddr,password)
server.sendmail(fromaddr,toaddr,message)
print "Success"
server.quit()
我需要在“收件人”
的收件箱中收到Receiver电子邮件答案 0 :(得分:0)
使用此格式来格式化消息:
message = 'Subject: {}\nTo: {}\n\n{}'.format("imp", toaddr, "testing file")
您可能还想要一个" From"字段:
message = 'Subject: {}\nTo: {}\nFrom: {}\n\n{}'.format("imp", toaddr, fromaddr, "testing file")