File size: 1,124 Bytes
784b9d2
55dc54d
784b9d2
55dc54d
 
 
 
 
784b9d2
55dc54d
 
784b9d2
55dc54d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65e9f27
55dc54d
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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()