Spaces:
Running
Running
Delete emails_utils.py
Browse files- emails_utils.py +0 -32
emails_utils.py
DELETED
|
@@ -1,32 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import requests
|
| 3 |
-
from dotenv import load_dotenv
|
| 4 |
-
load_dotenv()
|
| 5 |
-
|
| 6 |
-
SENDGRID_API_KEY = os.getenv("SENDGRID_API_KEY")
|
| 7 |
-
SENDER_EMAIL = os.getenv("SENDER_EMAIL")
|
| 8 |
-
|
| 9 |
-
def send_otp_email(receiver_email, otp):
|
| 10 |
-
url = "https://api.sendgrid.com/v3/mail/send"
|
| 11 |
-
|
| 12 |
-
headers = {
|
| 13 |
-
"Authorization": f"Bearer {SENDGRID_API_KEY}",
|
| 14 |
-
"Content-Type": "application/json"
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
data = {
|
| 18 |
-
"personalizations": [{
|
| 19 |
-
"to": [{"email": receiver_email}]
|
| 20 |
-
}],
|
| 21 |
-
"from": {"email": SENDER_EMAIL},
|
| 22 |
-
"subject": "Your FitPlan AI OTP",
|
| 23 |
-
"content": [{
|
| 24 |
-
"type": "text/plain",
|
| 25 |
-
"value": f"Your OTP is: {otp}"
|
| 26 |
-
}]
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
response = requests.post(url, headers=headers, json=data)
|
| 30 |
-
|
| 31 |
-
if response.status_code != 202:
|
| 32 |
-
raise Exception("Failed to send email")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|