Clarion02WebpageSniffer/sendEmailAlertPython.py
2026-04-02 10:34:17 -04:00

34 lines
1.2 KiB
Python

import smtplib
from email.message import EmailMessage
def send_email_alert():
TO = "jakesclarion02alerts@gmail.com, m24b@fsu.edu, mwheeler4@fsu.edu, vtripath@fsu.edu" # recipient
FROM = "jakesclarion02alerts@gmail.com" # must match Gmail account
PASSWORD = "xwhqmgkcjhbyiuck" # 16-char App Password
msg = EmailMessage()
msg.set_content("The webpage did not update!")
msg['Subject'] = "WEBPAGE NOT UPDATED!!"
msg['From'] = FROM
msg['To'] = TO
try:
print("Connecting to Gmail SMTP...")
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
#print("Logging in...")
smtp.login(FROM, PASSWORD)
#print("Sending email...")
smtp.send_message(msg)
#print("Email sent successfully!")
except smtplib.SMTPAuthenticationError:
#print("[ERROR] Authentication failed. Check your App Password and FROM address.")
except smtplib.SMTPConnectError:
#print("[ERROR] Could not connect to the SMTP server.")
except Exception as e:
#print(f"[ERROR] Other error: {e}")
if __name__ == "__main__":
send_email_alert()
#print("Email sent successfully.")