Update emailx.py
Browse files
emailx.py
CHANGED
@@ -11,7 +11,7 @@ MAILJET_API_SECRET = os.environ['MAILJET_API_SECRET']
|
|
11 |
# Create a Mailjet client
|
12 |
mailjet = Client(auth=(MAILJET_API_KEY, MAILJET_API_SECRET), version='v3.1')
|
13 |
|
14 |
-
def send_verification_email(to_email,
|
15 |
# Create the email message
|
16 |
email_data = {
|
17 |
'Messages': [
|
@@ -26,8 +26,8 @@ def send_verification_email(to_email, verification_token):
|
|
26 |
"Name": "User Name"
|
27 |
}
|
28 |
],
|
29 |
-
"Subject": "
|
30 |
-
"HTMLPart": f'
|
31 |
}
|
32 |
]
|
33 |
}
|
@@ -36,13 +36,9 @@ def send_verification_email(to_email, verification_token):
|
|
36 |
try:
|
37 |
response = mailjet.send.create(data=email_data)
|
38 |
if response.status_code == 200:
|
39 |
-
print(
|
40 |
-
print(response.json())
|
41 |
-
print("Verification email sent successfully.")
|
42 |
else:
|
43 |
-
print("Failed to send
|
44 |
-
print(response.status_code)
|
45 |
-
print(response.json())
|
46 |
except Exception as e:
|
47 |
print(str(e))
|
48 |
|
|
|
11 |
# Create a Mailjet client
|
12 |
mailjet = Client(auth=(MAILJET_API_KEY, MAILJET_API_SECRET), version='v3.1')
|
13 |
|
14 |
+
def send_verification_email(to_email, reset_link):
|
15 |
# Create the email message
|
16 |
email_data = {
|
17 |
'Messages': [
|
|
|
26 |
"Name": "User Name"
|
27 |
}
|
28 |
],
|
29 |
+
"Subject": "Reset or verifie",
|
30 |
+
"HTMLPart": f'Please click <a href="{reset_link}">here</a> to reset password or verifie your email.'
|
31 |
}
|
32 |
]
|
33 |
}
|
|
|
36 |
try:
|
37 |
response = mailjet.send.create(data=email_data)
|
38 |
if response.status_code == 200:
|
39 |
+
print("Password reset email sent successfully.")
|
|
|
|
|
40 |
else:
|
41 |
+
print("Failed to send password reset email.")
|
|
|
|
|
42 |
except Exception as e:
|
43 |
print(str(e))
|
44 |
|