I am trying to send an email in python. Here is my code.
import smtplib
if __name__ == '__main__':
SERVER = "localhost"
FROM = "sender@example.com"
TO = ["wmh1993@gmail.com"]
SUBJECT = "Hello!"
TEXT = "This message was sent with Python smtplib."
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO[0], message)
server.quit()
print "Message sent!"
This runs without error, but wmh1993@gmail.comno email is sent.
Questions
One thing I donβt understand about this code: what limitations do I have when setting up a field FROM?
Do I have to say somehow that it was from my computer?
What happens so as not to disturb someone else?
Or am I free to do this?
source
share