Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import smtplib | |
| def send_email(name, email, message): | |
| # Replace with your email credentials | |
| sender_email = "your_email@gmail.com" | |
| sender_password = "your_password" | |
| receiver_email = "recipient_email@example.com" | |
| # Create a secure SSL context | |
| context = smtplib.SSLContext() | |
| # Connect to the Gmail SMTP server | |
| with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server: | |
| server.login(sender_email, sender_password) | |
| # Craft the email message | |
| subject = "New Message from Your Website" | |
| body = f"Name: {name}\nEmail: {email}\nMessage: {message}" | |
| message = f"Subject: {subject}\n\n{body}" | |
| # Send the email | |
| server.sendmail(sender_email, receiver_email, message) | |
| return "Email sent successfully!" | |
| # Create the Gradio interface | |
| iface = gr.Interface( | |
| fn=send_email, | |
| inputs=[ | |
| gr.Textbox(label="Name"), | |
| gr.Textbox(label="Email"), | |
| gr.Textbox(label="Message"), | |
| ], | |
| outputs="text", | |
| title="Contact Us", | |
| ) | |
| # Add a logo to the top center | |
| iface.logo = "/src/renesis-tech.jpg" | |
| # Launch the Gradio app | |
| iface.launch() |