-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (25 loc) · 771 Bytes
/
main.py
File metadata and controls
30 lines (25 loc) · 771 Bytes
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
import config
import smtplib
import requests
# Configurations
USER_EMAIL = config.USER_EMAIL
DEVICE_PASS = config.DEVICE_PASS
WEBSITE = config.WEBSITE
REC_EMAIL = config.RE_EMAIL
def nofity():
with smtplib.SMTP('smtp.gmail.com',587) as smtp:
smtp.ehlo()
smtp.starttls()
smtp.ehlo()
smtp.login(USER_EMAIL,DEVICE_PASS)
# Email Subject
subject = "SOMETHING WENT WRONG WITH YOUR WEBSITE!!"
body = "Your Website is down please check, backup and restart the server"
msg = "Subject: {} \n\n {}".format(subject,body)
smtp.sendmail(USER_EMAIL,REC_EMAIL,msg)
try:
r = requests.get(WEBSITE, timeout=5)
if r.status_code != 200:
nofity()
except Exception as e:
nofity()