Karan6124 commited on
Commit
75aaa5e
·
1 Parent(s): e9fefa4

fix: propagate SMTP exceptions in diagnostic endpoint to display exact SMTP error details

Browse files
backend/app/api/endpoints.py CHANGED
@@ -361,7 +361,7 @@ async def test_email(email: str = None):
361
 
362
  try:
363
  # Run synchronous send directly to capture the exact exception stack trace
364
- result = send_verification_email(to_email, "123456")
365
  if result:
366
  return {
367
  "success": True,
 
361
 
362
  try:
363
  # Run synchronous send directly to capture the exact exception stack trace
364
+ result = send_verification_email(to_email, "123456", raise_on_error=True)
365
  if result:
366
  return {
367
  "success": True,
backend/app/services/email_service.py CHANGED
@@ -111,7 +111,7 @@ def send_price_alert_email(to_email: str, ticker: str, condition: str, target_pr
111
  return False
112
 
113
 
114
- def send_verification_email(to_email: str, code: str) -> bool:
115
  """
116
  Sends a registration verification OTP email using SMTP config, or logs to console as a fallback.
117
  """
@@ -196,4 +196,6 @@ def send_verification_email(to_email: str, code: str) -> bool:
196
  return True
197
  except Exception as e:
198
  logger.error(f"Failed to send verification email via SMTP host {settings.SMTP_HOST}: {e}")
 
 
199
  return False
 
111
  return False
112
 
113
 
114
+ def send_verification_email(to_email: str, code: str, raise_on_error: bool = False) -> bool:
115
  """
116
  Sends a registration verification OTP email using SMTP config, or logs to console as a fallback.
117
  """
 
196
  return True
197
  except Exception as e:
198
  logger.error(f"Failed to send verification email via SMTP host {settings.SMTP_HOST}: {e}")
199
+ if raise_on_error:
200
+ raise e
201
  return False