webcodelab commited on
Commit
ae20797
·
verified ·
1 Parent(s): f47575e

Update app/email_utils.py

Browse files
Files changed (1) hide show
  1. 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("❌", error_msg)
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.SMTP_SSL('smtp.gmail.com', 465) as server:
 
35
  server.login(from_email, app_password)
36
  server.send_message(msg)
37
- print(f"✅ Email sent to {to_email}")
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))