-
Notifications
You must be signed in to change notification settings - Fork 5
/
IOTNOTIFY2.py
31 lines (23 loc) · 914 Bytes
/
IOTNOTIFY2.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
28
29
30
31
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from smtplib import SMTP
import smtplib
import sys
recipients = ['<YourEmail>']
emaillist = [elem.strip().split(',') for elem in recipients]
msg = MIMEMultipart()
msg['Subject'] = str(sys.argv[1])
msg['From'] = '<From Email>'
msg['Reply-to'] = '[email protected]'
msg.preamble = 'Multipart massage.\n'
part = MIMEText("Hello Sir/Ma'am, There is some one at your door. A picture of this person has been atached.")
msg.attach(part)
part = MIMEApplication(open(str(sys.argv[2]),"rb").read())
part.add_header('Content-Disposition', 'attachment', filename=str(sys.argv[2]))
msg.attach(part)
server = smtplib.SMTP("smtp.gmail.com:587")
server.ehlo()
server.starttls()
server.login('<From Email>','<From password>')
server.sendmail(msg['From'], emaillist , msg.as_string())