-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailer.py
31 lines (26 loc) · 1.26 KB
/
mailer.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
import smtplib, ssl
class Mailer:
"""
This script initiaties the email alert function.
"""
def __init__(self):
# Enter your email below. This email will be used to send alerts.
# E.g., "email@gmail.com"
self.EMAIL = "eyosiAi2021@gmail.com"
# Enter the email password below. Note that the password varies if you have secured
# 2 step verification turned on. You can refer the links below and create an application specific password.
# Google mail has a guide here: https://myaccount.google.com/lesssecureapps
# For 2 step verified accounts: https://support.google.com/accounts/answer/185833
self.PASS = "slhogcdxhsidzxth"
self.PORT = 465
self.server = smtplib.SMTP_SSL('smtp.gmail.com', self.PORT)
def send(self, mail):
self.server = smtplib.SMTP_SSL('smtp.gmail.com', self.PORT)
self.server.login(self.EMAIL, self.PASS)
# message to be sent
SUBJECT = 'ALERT!'
TEXT = f'Please violence is detected so Please reach there fast as much as posibile!'
message = 'Subject: {}\n\n{}'.format(SUBJECT, TEXT)
# sending the mail
self.server.sendmail(self.EMAIL, mail, message)
self.server.quit()