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()