I’m using the script below to send an email to myself, the script runs fine with no errors but I don’t physically receive an email.
import smtplib
sender = 'foo@hotmail.com'
receivers = ['foo@hotmail.com']
message = """From: From Person <foo@hotmail.com>
To: To Person <foo@hotmail.com>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"
EDIT
The script is named test.py
Why you use localhost as the SMTP?
If you are using hotmail you need to use hotmail account, provide the password, enter port and SMTP server etc.
Here is everything you need:
http://techblissonline.com/hotmail-pop3-and-smtp-settings/
edit:
Here is a example if you use gmail: