Spaces:
Runtime error
Runtime error
Update app/email_utils.py
Browse files- app/email_utils.py +4 -3
app/email_utils.py
CHANGED
|
@@ -9,7 +9,7 @@ def send_verification_email(to_email, username, token):
|
|
| 9 |
|
| 10 |
if not from_email or not app_password:
|
| 11 |
error_msg = f"Missing email env vars. EMAIL_HOST_USER={from_email}, EMAIL_HOST_PASSWORD={'SET' if app_password else 'MISSING'}"
|
| 12 |
-
print("
|
| 13 |
return {"error": error_msg}
|
| 14 |
|
| 15 |
subject = "Verify your account"
|
|
@@ -31,10 +31,11 @@ def send_verification_email(to_email, username, token):
|
|
| 31 |
msg.attach(MIMEText(body, 'plain'))
|
| 32 |
|
| 33 |
try:
|
| 34 |
-
with smtplib.
|
|
|
|
| 35 |
server.login(from_email, app_password)
|
| 36 |
server.send_message(msg)
|
| 37 |
-
print(f"
|
| 38 |
return True
|
| 39 |
except Exception as e:
|
| 40 |
print("❌ Email error:", str(e))
|
|
|
|
| 9 |
|
| 10 |
if not from_email or not app_password:
|
| 11 |
error_msg = f"Missing email env vars. EMAIL_HOST_USER={from_email}, EMAIL_HOST_PASSWORD={'SET' if app_password else 'MISSING'}"
|
| 12 |
+
print("", error_msg)
|
| 13 |
return {"error": error_msg}
|
| 14 |
|
| 15 |
subject = "Verify your account"
|
|
|
|
| 31 |
msg.attach(MIMEText(body, 'plain'))
|
| 32 |
|
| 33 |
try:
|
| 34 |
+
with smtplib.SMTP('smtp.gmail.com', 587) as server:
|
| 35 |
+
server.starttls()
|
| 36 |
server.login(from_email, app_password)
|
| 37 |
server.send_message(msg)
|
| 38 |
+
print(f" Email sent to {to_email}")
|
| 39 |
return True
|
| 40 |
except Exception as e:
|
| 41 |
print("❌ Email error:", str(e))
|