Wajahat698 commited on
Commit
08db173
·
verified ·
1 Parent(s): 4dc99c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -115,17 +115,20 @@ def feedback_email(name, email, feedback):
115
  print(f"EMAIL_PASSWORD: {os.getenv('Password')}")
116
  SMTP_SERVER = "smtp.office365.com"
117
  SMTP_PORT = 587
118
- msg = MIMEText(f"Name: {name}\nEmail: {email}\nFeedback: {feedback}", 'plain')
119
  msg['From'] = EMAIL_ADDRESS
120
  msg['To'] = "wajahat698@gmail.com"
121
  msg['Subject'] = "Feedback Received"
 
 
 
 
122
 
123
  try:
124
- with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
125
  server.starttls()
126
- server.login(EMAIL_ADDRESS, Password)
127
  server.send_message(msg)
128
- print("Feedback sent successfully!")
129
  except Exception as e:
130
  print(f"Error sending email: {e}")
131
 
@@ -175,9 +178,12 @@ with st.sidebar.form(key='feedback_form'):
175
  # Submit button within the form
176
  submit_button = st.form_submit_button("Submit Feedback")
177
  if submit_button:
 
178
  if feedback_name and feedback_email_input and feedback_text:
179
- feedback_email(feedback_name, feedback_email_input, feedback_text)
180
- st.success("Thank you for your feedback!")
 
 
181
  else:
182
  st.error("Please fill in all fields.")
183
 
 
115
  print(f"EMAIL_PASSWORD: {os.getenv('Password')}")
116
  SMTP_SERVER = "smtp.office365.com"
117
  SMTP_PORT = 587
 
118
  msg['From'] = EMAIL_ADDRESS
119
  msg['To'] = "wajahat698@gmail.com"
120
  msg['Subject'] = "Feedback Received"
121
+ body = f"Name: {name}\nEmail: {email}\nFeedback: {feedback}"
122
+
123
+ msg.attach(MIMEText(body, 'plain'))
124
+
125
 
126
  try:
127
+ ith smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
128
  server.starttls()
129
+ server.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
130
  server.send_message(msg)
131
+ print("Email sent successfully!")
132
  except Exception as e:
133
  print(f"Error sending email: {e}")
134
 
 
178
  # Submit button within the form
179
  submit_button = st.form_submit_button("Submit Feedback")
180
  if submit_button:
181
+
182
  if feedback_name and feedback_email_input and feedback_text:
183
+ with st.spinner('Sending email'):
184
+
185
+ feedback_email(feedback_name, feedback_email_input, feedback_text)
186
+ st.success("Thank you for your feedback!")
187
  else:
188
  st.error("Please fill in all fields.")
189