'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.



Solution 1:[1]

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.

Solution 2:[2]

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/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jomisore
Solution 2