icl-iot-weather/email_playground.py
2020-10-19 16:22:08 +01:00

17 lines
570 B
Python

import smtplib
import ssl
port = 465 # For SSL
smtp_server = "smtp.gmail.com"
sender_email = "iotdemax@gmail.com" # Enter your address
receiver_email = "mh2817@ic.ac.uk" # Enter receiver address
__PASSWORD_PATH = "secrets/email_password.txt"
with open(__PASSWORD_PATH, "r") as password_file:
password = password_file.read()
message = "Testing email..."
context = ssl.create_default_context()
with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message)