File size: 1,338 Bytes
34c5273 |
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 |
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:
# yagmail SMTP ๊ฐ์ฒด ์์ฑ
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)}"
# Gradio Blocks ์ธํฐํ์ด์ค ์์ฑ
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("๋ฉ์ผ ๋ฐ์ก") # ๋ฒํผ 1๊ฐ๋ง ํ์
# ๋ฒํผ ํด๋ฆญ ์ ํจ์ ํธ์ถ
button_send.click(fn=send_email, inputs=[subject_input, body_input], outputs=output)
# Gradio ์ฑ ์คํ
demo.launch()
|