-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifications.py
More file actions
25 lines (21 loc) · 838 Bytes
/
notifications.py
File metadata and controls
25 lines (21 loc) · 838 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
import smtplib
from email.mime.text import MIMEText
def send_email(camera_name, location, violation_type, timestamp, image_path):
sender = "your_email@gmail.com" # Replace with your email
receiver = "admin@example.com" # Replace with admin email
password = "your_app_password" # Replace with your email app password
subject = f"PPE Violation Detected - {camera_name}"
body = f"""Violation detected:
Camera: {camera_name}
Location: {location}
Type: {violation_type}
Time: {timestamp}
Image: {image_path}"""
msg = MIMEText(body)
msg["Subject"] = subject
msg["From"] = sender
msg["To"] = receiver
with smtplib.SMTP("smtp.gmail.com", 587) as server:
server.starttls()
server.login(sender, password)
server.sendmail(sender, receiver, msg.as_string())