|
import gradio as gr |
|
import yagmail |
|
|
|
|
|
SENDER_EMAIL = "[email protected]" |
|
APP_PASSWORD = "ctty dyti rfkn zxrt" |
|
RECIPIENT_EMAIL = "[email protected]" |
|
|
|
|
|
def send_email(subject, content): |
|
try: |
|
|
|
yag = yagmail.SMTP(SENDER_EMAIL, APP_PASSWORD) |
|
|
|
|
|
yag.send( |
|
to=RECIPIENT_EMAIL, |
|
subject=subject, |
|
contents=content |
|
) |
|
|
|
return "์ด๋ฉ์ผ์ด ์ฑ๊ณต์ ์ผ๋ก ๋ฐ์ก๋์์ต๋๋ค!" |
|
except Exception as e: |
|
return f"์ด๋ฉ์ผ ๋ฐ์ก ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}" |
|
|
|
|
|
with gr.Blocks() as demo: |
|
with gr.Row(): |
|
subject_input = gr.Textbox(label="๋ฉ์ผ ์ ๋ชฉ", placeholder="์ ๋ชฉ์ ์์ฑํ์ธ์.") |
|
with gr.Row(): |
|
body_input = gr.Textbox(label="๋ฉ์ผ ๋ด์ฉ", lines=5, placeholder="์ด๊ณณ์ ๋ฉ์ผ ๋ด์ฉ์ ์์ฑํ์ธ์.") |
|
with gr.Row(): |
|
output = gr.Textbox(label="๊ฒฐ๊ณผ", interactive=False) |
|
with gr.Row(): |
|
button_send = gr.Button("๋ฉ์ผ ๋ฐ์ก") |
|
|
|
|
|
button_send.click(fn=send_email, inputs=[subject_input, body_input], outputs=output) |
|
|
|
|
|
demo.launch() |
|
|