Python email by smtplib example

"""The first step is to create an SMTP object, each object is used for connection
with one server."""

import smtplib
server = smtplib.SMTP('smtp.i88.ca', 587)
#for debug
server.set_debuglevel(1)
#TLS
server.starttls()
#Next, log in to the server
server.login("user-name", "password")

#Send the mail
msg = "\n\nHello!" # The /n separates the message from the headers
server.sendmail("sender@i88.ca", "recipient@i88.ca", msg)
server.quit()


Comments