Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,14 +39,6 @@ if not openai_api_key or not serper_api_key:
|
|
| 39 |
openai.api_key = openai_api_key
|
| 40 |
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
EMAIL_ADDRESS = os.getenv("EMAIL_ADDRESS")
|
| 47 |
-
EMAIL_PASSWORD = os.getenv("EMAIL_PASSWORD")
|
| 48 |
-
SMTP_SERVER = "smtp.office365.com"
|
| 49 |
-
SMTP_PORT = 587
|
| 50 |
st.markdown("""
|
| 51 |
<style>
|
| 52 |
.custom-image img {
|
|
@@ -124,22 +116,25 @@ def feedback_email(name, email, feedback):
|
|
| 124 |
msg = MIMEMultipart()
|
| 125 |
msg['From'] = EMAIL_ADDRESS
|
| 126 |
msg['To'] = "wajahat698@gmail.com"
|
| 127 |
-
msg['Subject'] = "Feedback
|
| 128 |
body = f"Name: {name}\nEmail: {email}\nFeedback: {feedback}"
|
| 129 |
msg.attach(MIMEText(body, 'plain'))
|
| 130 |
-
|
| 131 |
-
try:
|
| 132 |
-
server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
|
| 133 |
-
server.starttls()
|
| 134 |
-
server.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
|
| 135 |
-
server.sendmail(EMAIL_ADDRESS, user_email, msg.as_string())
|
| 136 |
-
server.quit()
|
| 137 |
-
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
except Exception as e:
|
| 140 |
st.error(f"Error sending email: {e}")
|
| 141 |
|
| 142 |
-
|
| 143 |
with st.sidebar.form(key='feedback_form'):
|
| 144 |
|
| 145 |
st.image( "Trust Logic_Wheel_RGB_Standard.png")
|
|
|
|
| 39 |
openai.api_key = openai_api_key
|
| 40 |
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
st.markdown("""
|
| 43 |
<style>
|
| 44 |
.custom-image img {
|
|
|
|
| 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")
|