-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_mail.py
More file actions
29 lines (22 loc) · 1.04 KB
/
send_mail.py
File metadata and controls
29 lines (22 loc) · 1.04 KB
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
import smtplib
self.sendmail = options['motion']['sendmail']
self.smtp = options['motion']['smtp']
self.maillogin = options['motion']['maillogin']
self.mailpassword = options['motion']['mailpassword']
self.toaddress = options['motion']['toaddress']
if self.sendmail:
self.send_mail(filename)
def send_mail(self, msg):
try:
fromaddr = self.maillogin
toaddress = self.toaddress
password = self.mailpassword
smtp = self.smtp
message = 'Subject: {}\n\n{}'.format(socket.gethostname(), msg)
server = smtplib.SMTP_SSL(smtp)
server.login(fromaddr, password)
server.sendmail(fromaddr, toaddress, message)
server.quit()
except Exception as e:
flush_print('Error send mail: ' + str(e))
"sendmail": false, "smtp": "mail.linux.pl:465", "maillogin": "roberto@linux.pl", "mailpassword": "", "toaddress":"googrobbo@gmail.com"