{"id":14904,"library":"secure-smtplib","title":"secure-smtplib (Python 2)","description":"secure-smtplib is an abandoned Python 2 library (last released in 2015) that provides subclasses for the standard `smtplib` module to handle secure SMTP connections. Its functionality has been largely superseded by built-in improvements to the standard `smtplib` module in Python 3, which offers robust SSL/TLS support through `SMTP_SSL` and `starttls()` methods, often in conjunction with the `ssl` module. This library is not recommended for new projects or Python 3 environments due to its age and lack of maintenance.","status":"abandoned","version":"0.1.1","language":"en","source_language":"en","source_url":"https://github.com/graingert/secure-smtplib","tags":["email","smtp","ssl","tls","python2","abandoned"],"install":[{"cmd":"pip install secure-smtplib","lang":"bash","label":"Install secure-smtplib"}],"dependencies":[],"imports":[{"symbol":"SecureSMTP","correct":"from secure_smtplib import SecureSMTP"},{"symbol":"SecureSMTP_SSL","correct":"from secure_smtplib import SecureSMTP_SSL"}],"quickstart":{"code":"import smtplib\nimport ssl\nimport os\nfrom email.message import EmailMessage\n\n# NOTE: This quickstart uses Python 3's built-in smtplib and ssl modules,\n# which are the recommended and secure way to send emails. The `secure-smtplib`\n# library itself is deprecated and not suitable for modern Python or secure applications.\n\nSMTP_SERVER = os.environ.get('SMTP_HOST', 'smtp.example.com')\nSMTP_PORT = int(os.environ.get('SMTP_PORT', '465')) # Use 587 for STARTTLS\nEMAIL_ADDRESS = os.environ.get('SMTP_USERNAME', 'your_email@example.com')\nEMAIL_PASSWORD = os.environ.get('SMTP_PASSWORD', 'your_app_password') # Use app passwords if 2FA is enabled\n\nmsg = EmailMessage()\nmsg['Subject'] = 'Test Email from Python'\nmsg['From'] = EMAIL_ADDRESS\nmsg['To'] = 'recipient@example.com'\nmsg.set_content('This is a test email sent securely using Python 3 smtplib.')\n\ncontext = ssl.create_default_context()\n\ntry:\n    with smtplib.SMTP_SSL(SMTP_SERVER, SMTP_PORT, context=context) as server:\n        server.login(EMAIL_ADDRESS, EMAIL_PASSWORD)\n        server.send_message(msg)\n    print(\"Email sent successfully!\")\nexcept smtplib.SMTPAuthenticationError as e:\n    print(f\"Authentication error: {e}. Check your username and password/app password.\")\nexcept smtplib.SMTPServerDisconnected as e:\n    print(f\"Server disconnected unexpectedly: {e}. Check host and port.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to send a secure email using Python 3's built-in `smtplib` and `ssl` modules. This is the **recommended modern approach** for secure email communication and should be used **instead of** the `secure-smtplib` library, which is outdated. Ensure you set `SMTP_HOST`, `SMTP_PORT`, `SMTP_USERNAME`, and `SMTP_PASSWORD` environment variables for authentication."},"warnings":[{"fix":"Migrate to Python 3 and use the built-in `smtplib` and `ssl` modules for secure email functionality.","message":"This library is designed for Python 2 and is not compatible with Python 3. Attempting to use it in a Python 3 environment will likely result in import errors or unexpected behavior.","severity":"breaking","affected_versions":"0.1.1 and earlier"},{"fix":"Discontinue use of `secure-smtplib` and leverage the `smtplib` and `ssl` modules available in Python 3.","message":"The functionality provided by `secure-smtplib` for secure SMTP connections (SSL/TLS) has been integrated into and significantly improved within Python's standard `smtplib` module since Python 3.3. The standard library now offers `smtplib.SMTP_SSL` for implicit TLS and `smtplib.SMTP().starttls()` for explicit TLS, along with `ssl.create_default_context()` for robust security configuration.","severity":"deprecated","affected_versions":"0.1.1 and earlier"},{"fix":"Avoid using `secure-smtplib` in production or security-sensitive applications. Prioritize actively maintained libraries or the robust built-in `smtplib` module in Python 3 for secure email operations.","message":"The library is unmaintained (last updated in 2015) and specifically targets Python 2. Using unmaintained software, especially for network communication involving credentials, can introduce significant security vulnerabilities.","severity":"gotcha","affected_versions":"0.1.1 and earlier"}],"env_vars":null,"search_vec":"'2':5,13 '2015':18 '3':50,79 'abandon':11,94 'age':84 'built':40 'built-in':39 'conjunct':64 'connect':31 'due':81 'email':89 'environ':80 'function':33 'handl':28 'improv':42 'lack':86 'larg':36 'last':15 'librari':14,70 'mainten':88 'method':61 'modul':26,47,68 'new':75 'offer':52 'often':62 'project':76 'provid':20 'python':4,12,49,78 'python2':93 'recommend':73 'releas':16 'robust':53 'secur':2,7,29 'secure-smtplib':1,6 'smtp':30,57,90 'smtplib':3,8,25,46 'ssl':58,67,91 'ssl/tls':54 'standard':24,45 'starttl':60 'subclass':21 'supersed':37 'support':55 'tls':92","created_at":"2026-04-20T18:44:12.827196+00:00","updated_at":"2026-04-20T18:44:12.827196+00:00","problems":[],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-14","install_tag":null}}