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
  • 349
  • 6
  • 11
  • 1
    Is your script called email.py or do you have a file with that name in your directory? – Daniel Hepper Aug 17 '15 at 17:26
  • May not be very helpful, but the python code from the Sending Mail link works (gets past the import) on python 2.7.8 32-bit on Windows x64. – barny Aug 17 '15 at 17:35

3 Answers3

2

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
  • 349
  • 6
  • 11
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,456
  • 3
  • 23
  • 24
0

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
  • 5,501
  • 18
  • 69
  • 107