Create alerts.py
Browse files- ai-bot/utils/alerts.py +22 -0
ai-bot/utils/alerts.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import smtplib
|
| 2 |
+
|
| 3 |
+
ADMIN_EMAIL = "your@email.com"
|
| 4 |
+
|
| 5 |
+
def send_alert(message: str):
|
| 6 |
+
print("ALERT:", message)
|
| 7 |
+
|
| 8 |
+
# simpele mail (kan je uitbreiden)
|
| 9 |
+
try:
|
| 10 |
+
server = smtplib.SMTP("smtp.gmail.com", 587)
|
| 11 |
+
server.starttls()
|
| 12 |
+
server.login("your@email.com", "yourpassword")
|
| 13 |
+
|
| 14 |
+
server.sendmail(
|
| 15 |
+
"your@email.com",
|
| 16 |
+
ADMIN_EMAIL,
|
| 17 |
+
message
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
server.quit()
|
| 21 |
+
except Exception as e:
|
| 22 |
+
print("Mail failed:", e)
|