1

I am trying to send emails from the python script following this thread Sending mail from Python using SMTP

But I am getting an error while doing this:

from smtplib import SMTP_SSL as SMTP

Error: ImportError: cannot import name SMTP_SSL

I am using python2.7.10 and I downloaded it from https://www.python.org/downloads/

Can anybody guess what can be the reason for the error. Please note that the name of script is not email.py

Community
  • 1
  • 1
user2793078
  • 419
  • 7
  • 12

3 Answers3

3

The problem has been solved as I created a file email.py previously but after finding related issues I created another file with different name

But I found that even the presence of email.py in the directory causes problem. After deleting the email.py the script is not causing any issue in running

user2793078
  • 419
  • 7
  • 12
1

NEVER EVER CREATE YOUR FILENAME WITH 'email.py' that's gonna cause a lot of issues. I was facing the same issue and as I rename the file the problem got sorted out. The issue could be with the same name as python could have an inbuild email module. I was trying to import the below modules

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
Varun
  • 4,342
  • 19
  • 84
  • 119
0

I suspect that while you may have downloaded and installed Python 2.7.10, you're actually running a version of python earlier than 2.6 when you execute python from the command line.

Can you execute:

python -V

And post the results?

Joe Young
  • 5,749
  • 3
  • 28
  • 27