1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | def emailsend(subjectPart, messagePart): # usage: emailsend("Server is up", "") import time import smtplib import socket from datetime import datetime current_utc = datetime.utcnow().isoformat() + 'Z' ####--[CONFIGURATION] server = 'smtp.gmail.com' server_port = '587' username = 'INSERT-YOUR-USERNAME@gmail.com' password = 'INSERT-YOUR-PASSWORD' fromaddr = 'INSERT-YOUR-FROM-NAME <INSERT-YOUR-FROM@gmail.com>' toaddr = 'INSERT-YOUR-TO-EMAIL' subject = 'INSERT-YOUR-SUBJECT-PREPEND | ' + socket.gethostname() + ' | ' + subjectPart message = 'INSERT-YOUR-MESSAGE-PREPEND | ' + socket.gethostname() + ' | <br>' + messagePart + '<br><br><br>Email Generated On: ' + current_utc ####--[/CONFIGURATION] headers = [ "Subject: " + subject, "From: " + fromaddr, "To: " + toaddr, "MIME-Version: 1.0", "Content-Type: text/html" ] headers = "\r\n".join(headers) server = smtplib.SMTP(server + ":" + server_port) server.ehlo() server.starttls() server.ehlo() server.login(username,password) server.sendmail(fromaddr, toaddr, headers + "\r\n\r\n" + message) server.quit() |
2019-11-16
Python 3 Script to Send Email via Gmail (tested on RPI)
Subscribe to:
Post Comments (Atom)
-
Word for Windows with Merge Fields and problem during Print Preview ISSUE: Document merges normally and shows all the fields. When CTRL-P is...
-
Stop MS Edge from running in background when Edge is closed In MS Edge Navigate to: edge://settings/?search=startup Uncheck " Startup b...
-
Start|cmd|Right-Click|Run as administrator C:\Windows\system32 > powershell Windows PowerShell Copyright (C) 2009 Microsoft Corpor...
No comments:
Post a Comment