Skip to content

Instantly share code, notes, and snippets.

@jamescalam
jamescalam / smtp_example.py
Created May 26, 2020 16:53
Example code for sending an email via SMTP with TLS encryption in Python.
import smtplib
# initialize connection to our email server, we will use Outlook here
smtp = smtplib.SMTP('smtp-mail.outlook.com', port='587')
smtp.ehlo() # send the extended hello to our server
smtp.starttls() # tell server we want to communicate with TLS encryption
smtp.login('joe.bloggs@outlook.com', 'Password123') # login to our email server