Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -117,7 +117,7 @@ def copy_to_clipboard(text):
|
|
| 117 |
|
| 118 |
def send_feedback_via_email(name, email, feedback):
|
| 119 |
"""Sends an email with feedback details."""
|
| 120 |
-
smtp_server = 'smtp.
|
| 121 |
smtp_port = 465 # Typically 587 for TLS, 465 for SSL
|
| 122 |
smtp_user = os.getenv("EMAIL_ADDRESS")
|
| 123 |
smtp_password = os.getenv("Password")
|
|
@@ -131,11 +131,16 @@ def send_feedback_via_email(name, email, feedback):
|
|
| 131 |
msg.attach(MIMEText(body, 'plain'))
|
| 132 |
|
| 133 |
try:
|
| 134 |
-
with smtplib.SMTP(smtp_server, smtp_port) as server:
|
| 135 |
-
server.
|
|
|
|
| 136 |
server.login(smtp_user, smtp_password)
|
| 137 |
server.sendmail(smtp_user, email, msg.as_string())
|
| 138 |
st.success("Feedback sent via email successfully!")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
except Exception as e:
|
| 140 |
st.error(f"Error sending email: {e}")
|
| 141 |
|
|
|
|
| 117 |
|
| 118 |
def send_feedback_via_email(name, email, feedback):
|
| 119 |
"""Sends an email with feedback details."""
|
| 120 |
+
smtp_server = 'smtp.office365.com'
|
| 121 |
smtp_port = 465 # Typically 587 for TLS, 465 for SSL
|
| 122 |
smtp_user = os.getenv("EMAIL_ADDRESS")
|
| 123 |
smtp_password = os.getenv("Password")
|
|
|
|
| 131 |
msg.attach(MIMEText(body, 'plain'))
|
| 132 |
|
| 133 |
try:
|
| 134 |
+
with smtplib.SMTP(smtp_server, smtp_port, timeout=10) as server:
|
| 135 |
+
server.set_debuglevel(1) # Enable debug output for troubleshooting
|
| 136 |
+
server.starttls()
|
| 137 |
server.login(smtp_user, smtp_password)
|
| 138 |
server.sendmail(smtp_user, email, msg.as_string())
|
| 139 |
st.success("Feedback sent via email successfully!")
|
| 140 |
+
except smtplib.SMTPConnectError:
|
| 141 |
+
st.error("Failed to connect to the SMTP server. Check server settings and network connectivity.")
|
| 142 |
+
except smtplib.SMTPAuthenticationError:
|
| 143 |
+
st.error("Authentication failed. Check email and password.")
|
| 144 |
except Exception as e:
|
| 145 |
st.error(f"Error sending email: {e}")
|
| 146 |
|