Wajahat698 commited on
Commit
347d713
·
verified ·
1 Parent(s): 530e524

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -113,28 +113,20 @@ def feedback_email(name, email, feedback):
113
  EMAIL_PASSWORD = os.getenv("EMAIL_PASSWORD")
114
  SMTP_SERVER = "smtp.office365.com"
115
  SMTP_PORT = 587
116
- msg = MIMEMultipart()
117
  msg['From'] = EMAIL_ADDRESS
118
  msg['To'] = "wajahat698@gmail.com"
119
  msg['Subject'] = "Feedback Received"
120
- body = f"Name: {name}\nEmail: {email}\nFeedback: {feedback}"
121
- msg.attach(MIMEText(body, 'plain'))
122
 
123
  try:
124
  with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
125
  server.starttls()
126
  server.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
127
  server.send_message(msg)
128
- st.success("Feedback sent successfully!")
129
- except smtplib.SMTPAuthenticationError:
130
- st.error("SMTP Authentication Error: Check your email address and password.")
131
- except smtplib.SMTPConnectError:
132
- st.error("SMTP Connection Error: Unable to connect to the SMTP server.")
133
- except smtplib.SMTPException as e:
134
- st.error(f"SMTP error: {e}")
135
  except Exception as e:
136
- st.error(f"Error sending email: {e}")
137
-
138
  with st.sidebar.form(key='feedback_form'):
139
 
140
  st.image( "Trust Logic_Wheel_RGB_Standard.png")
 
113
  EMAIL_PASSWORD = os.getenv("EMAIL_PASSWORD")
114
  SMTP_SERVER = "smtp.office365.com"
115
  SMTP_PORT = 587
116
+ msg = MIMEText(f"Name: {name}\nEmail: {email}\nFeedback: {feedback}", 'plain')
117
  msg['From'] = EMAIL_ADDRESS
118
  msg['To'] = "wajahat698@gmail.com"
119
  msg['Subject'] = "Feedback Received"
 
 
120
 
121
  try:
122
  with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
123
  server.starttls()
124
  server.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
125
  server.send_message(msg)
126
+ print("Feedback sent successfully!")
 
 
 
 
 
 
127
  except Exception as e:
128
+ print(f"Error sending email: {e}")
129
+
130
  with st.sidebar.form(key='feedback_form'):
131
 
132
  st.image( "Trust Logic_Wheel_RGB_Standard.png")