How do I do it?
I couldn't find a working code online, please help.
Code: Select all
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
GMAIL_USERNAME = ''
GMAIL_PASSWORD = '' #CAUTION: This is stored in plain text!
recipient = ''
subject = 'The Temperature In Your Room'
emailText = z
emailText = "" + emailText + ""
headers = ["From: " + GMAIL_USERNAME,
"Subject: " + subject,
"To: " + recipient,
"MIME-Version: 1.0",
"Content-Type: text/html"]
headers = "\r\n".join(headers)
session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
session.ehlo()
session.starttls()
session.ehlo
session.login(GMAIL_USERNAME, GMAIL_PASSWORD)
session.sendmail(GMAIL_USERNAME, recipient, headers + "\r\n\r\n" + emailText)
email(0)