Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python smtplib has no attribute SMTP_SSL

I'm try to send an email with SMTP_SSL (the mail server does not support smtp).

import smtp
s = smtp.SMTP_SSL('xxxxx')

I get an error:

module object has no attribute 'SMTP_SSL'

I don't quite understand why python smptlib has no attribute SMTP_SSL given that the python documentation shows that SMTP_SSL has this attribute.

like image 970
pgyzhu Avatar asked May 10 '17 13:05

pgyzhu


2 Answers

Either your script's name is email.py or you have another script in your directory named email.py. You should change the name of the script.

like image 85
jomisore Avatar answered Sep 22 '22 05:09

jomisore


When python is compiled without ssl support, you get an smtp module without the expected attribute: SMTP_SSL.

This happens sometimes when openssl is not automatically detected, maybe some dependency isn't installed on the system when python was built.

Here is a tutorial on how to overcome that: https://techglimpse.com/install-python-openssl-support-tutorial/

like image 30
tenuki Avatar answered Sep 25 '22 05:09

tenuki