-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc_email.py
28 lines (27 loc) · 949 Bytes
/
func_email.py
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
def alart_email():
sender = "[email protected]"
recipient = "[email protected]"
cc = "[email protected]"
email_subject = "SAFE ALART - DOOR OPEN"
email_body = "I've detected that the door of the safe is OPEN!"
headers = "\r\n".join([
"from: " + sender,
"subject: " + email_subject,
"to: " + recipient,
"cc: " + cc,
"mime-version: 1.0",
"content-type: text/html"])
toaddrs = [recipient, cc]
content = headers + "\r\n\r\n" + email_body
try:
session = smtplib.SMTP('smtp.gmail.com',587)
session.set_debuglevel(0)
session.ehlo()
session.starttls()
session.ehlo()
session.login(sender,'vygqvutorvirnpsa')
session.sendmail(sender,toaddrs,content)
session.quit()
except smtplib.SMTPException:
print('Error')
return;