send email to localhost from localhost via python
问题 I'm building and testing a web service on my local machine before i put it in production. I want to test the mail service. I'm using the standard python email and smtplib libraries. import smtplib from email.mime.text import MIMEText fp = open('textfile', 'rb') msg = MIMEText(fp.read()) fp.close() me = 'me_email@localhost' you = 'me_again_email@localhost' msg['Subject'] = 'The contents of %s' %fp msg['From'] = me msg['To'] = you s = smtplib.SMTP('localhost') s.sendmail(me, [you], msg.as