Send Email (Python)

#!/usr/bin/python


# Import Libraries
import os
import smtplib


# Initialize Variables
server = "smtpserver"
port = 25
debug = 0
timeout = 30
recipient = "recipient@domain.com"
sender = "sender@domain.com"
password = "password
"subject = "subject"
body = "Hello, World"
message = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n%s\r\n\r\n"
% (sender, recipient, subject, body))


# Connect to SMTP Server and send message
smtp = smtplib.SMTP(server, port, hostname)
smtp.set_debuglevel(debug)
smtp.login(sender, password)
smtp.sendmail(sender, recipient, message)
smtp.quit()

Document Actions