Wajahat698 commited on
Commit
6869e0b
·
verified ·
1 Parent(s): 55424f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -108,13 +108,13 @@ def copy_to_clipboard(text):
108
 
109
 
110
 
111
- def feedback_email(name, feedback):
112
- """Sends feedback via email."""
113
- EMAIL_ADDRESS = "intouch@trustlogic.info"
114
- EMAIL_PASSWORD = "1nt0uch35pak" # Ensure this environment variable is set correctly
115
  SMTP_SERVER = "smtp.office365.com"
116
- SMTP_PORT = 587
117
-
118
  if not EMAIL_ADDRESS or not EMAIL_PASSWORD:
119
  st.error("Email configuration is missing.")
120
  return
@@ -123,11 +123,16 @@ def feedback_email(name, feedback):
123
  msg['From'] = EMAIL_ADDRESS
124
  msg['To'] = "wajahat698@gmail.com"
125
  msg['Subject'] = "Feedback Received"
126
- body = "Test 123"
127
  msg.attach(MIMEText(body, 'plain'))
128
 
129
  try:
130
- with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
 
 
 
 
 
131
  server.starttls()
132
  server.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
133
  server.send_message(msg)
@@ -135,7 +140,7 @@ def feedback_email(name, feedback):
135
  except smtplib.SMTPException as e:
136
  st.error(f"SMTP error: {e}")
137
  except Exception as e:
138
- st.error(f"Error sending email: {e}")
139
 
140
  def side():
141
  with st.sidebar.form(key='feedback_form'):
 
108
 
109
 
110
 
111
+ def feedback_email(name, email, feedback):
112
+ """Sends feedback via email using SMTP."""
113
+ EMAIL_ADDRESS = os.getenv("EMAIL_ADDRESS")
114
+ EMAIL_PASSWORD = os.getenv("EMAIL_PASSWORD") # Ensure this environment variable is set correctly
115
  SMTP_SERVER = "smtp.office365.com"
116
+ SMTP_PORT = 587
117
+
118
  if not EMAIL_ADDRESS or not EMAIL_PASSWORD:
119
  st.error("Email configuration is missing.")
120
  return
 
123
  msg['From'] = EMAIL_ADDRESS
124
  msg['To'] = "wajahat698@gmail.com"
125
  msg['Subject'] = "Feedback Received"
126
+ body = f"Name: {name}\nEmail: {email}\nFeedback: {feedback}"
127
  msg.attach(MIMEText(body, 'plain'))
128
 
129
  try:
130
+ # Debugging: Print the email content
131
+ st.write(f"Sending email to {msg['To']} with subject '{msg['Subject']}'")
132
+ st.write(f"Email body:\n{body}")
133
+
134
+ with smtplib.SMTP(SMTP_SERVER, SMTP_PORT, timeout=10) as server:
135
+ server.set_debuglevel(1) # Enable debug output
136
  server.starttls()
137
  server.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
138
  server.send_message(msg)
 
140
  except smtplib.SMTPException as e:
141
  st.error(f"SMTP error: {e}")
142
  except Exception as e:
143
+ st.error(f"Error sending email: {e}")
144
 
145
  def side():
146
  with st.sidebar.form(key='feedback_form'):