Spaces:
Build error
Build error
Update app.py
Browse files
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 |
-
|
| 125 |
server.starttls()
|
| 126 |
-
server.login(EMAIL_ADDRESS,
|
| 127 |
server.send_message(msg)
|
| 128 |
-
print("
|
| 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 |
-
|
| 180 |
-
|
|
|
|
|
|
|
| 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 |
|