From 9df78a9d6fb1d79c37932a3c495e7ef28590a381 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 26 Sep 2022 12:24:59 +0000 Subject: [PATCH] Add email file! Oops. --- undercover/email.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 undercover/email.py diff --git a/undercover/email.py b/undercover/email.py new file mode 100644 index 0000000..70f426f --- /dev/null +++ b/undercover/email.py @@ -0,0 +1,34 @@ +from mailjet_rest import Client +import os + +api_key = os.environ['MAILJET_API_KEY'] +api_secret = os.environ['MAILJET_SECRET_KEY'] + +mailjet = Client(auth=(api_key, api_secret), version='v3.1') + +def send_password_reset(to_email: str, reset_link: str): + data = { + 'Messages': [ + { + "From": { + "Email": "donotreply@undercover.cafe", + "Name": "UnderCover" + }, + "To": [ + { + "Email": to_email + # "Name": "Sage" + } + ], + "Subject": "UnderCover - Password Reset", + "TextPart": "Complete your UnderCover password reset by visiting " + reset_link, + "HTMLPart": "

Click here to complete your UnderCover password reset


Or copy and paste this link into your browser: " + reset_link, + "CustomID": "PasswordResetLink" + } + ] + } + + result = mailjet.send.create(data=data) + print(result.status_code) + print(result.json()) +