Category: smtplib

Problem

Send plain-text email with smtplib.

Solution

  with smtplib.SMTP("smtp.example.com", 587) as s:
    s.starttls()
    s.login(user, password)
    s.send_message(msg)
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path