My email program will not send – written in Python

I have here some Python code to send an email, but it will not send, and will give me an error. The code is listed below:

import smtplib
#SERVER = "localhost"

FROM = "[email protected]'

TO = ["[email protected]"]

SUBJECT = "Hello!"

TEXT = "This message was sent with Python's smtplib."


message = """
From: %s
To: %s
Subject: %s

%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)


server = smtplib.SMTP('myserver')
server.sendmail(FROM, TO, message)
server.quit()

It will keep throwing the same error, no matter what the code is:

AttributeError: partially initialized module 'smtplib' has no attribute 'SMTP' (most likely due to a circular import)

Can anyone help?

Answer

Perhaps this has the solution if your module is named email.py: No attribute ‘SMTP’, error when trying to send email in Python It would seem smtplib also has an email.py and a collision is occurring. My $0.02 worth. Please have mercy. I’m also new to StackOverflow.