I'm trying to send an email using smtplib without storing smtp credentials locally. I found this article https://www.tutorialspoint.com/python/python_sending_email.htm but get an error. I've fairly new with smtplib. Any help would be appreciated.
#!/usr/bin/python
import smtplib
message = """From: From Person <from@fromdomain.com>
To: To Person <to@todomain.com>
MIME-Version: 1.0
Content-type: text/html
Subject: SMTP HTML e-mail test
This is an e-mail message to be sent in HTML format
<b>This is HTML message.</b>
<h1>This is headline.</h1>
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"
error
NameError: name 'SMTPException' is not defined