MCPcopy Create free account
hub / github.com/N4si/microservices-python-app / notification

Function notification

src/notification-service/send/email.py:4–22  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

2from email.message import EmailMessage
3
4def notification(message):
5 message = json.loads(message)
6 mp3_fid = message["mp3_fid"]
7 sender_address = os.environ.get("GMAIL_ADDRESS")
8 sender_password = os.environ.get("GMAIL_PASSWORD")
9 receiver_address = message["username"]
10
11 msg = EmailMessage()
12 msg.set_content(f"mp3 file_id: {mp3_fid} is now ready!")
13 msg["Subject"] = "MP3 Download"
14 msg["From"] = sender_address
15 msg["To"] = receiver_address
16
17 session = smtplib.SMTP("smtp.gmail.com", 587)
18 session.starttls()
19 session.login(sender_address, sender_password)
20 session.send_message(msg, sender_address, receiver_address)
21 session.quit()
22 print("Mail Sent")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected