How do I send mail from a Python script?
Use the standard smtplib module.
Here’s a simple example that creates a message body and sends it to one or more recipients. This method will work on any host that supports an SMTP listener.
import smtplib SERVER = "localhost" FROM = "sender@example.com" TO = ["user@example.com"] # must be a list SUBJECT = "Hello!" TEXT = "This message was sent with Python's smtplib." # Prepare actual message message = """\ From: %s To: %s Subject: %s