email-parser / app.py
Nikhil Singh
All prints
56c79b1
raw
history blame
655 Bytes
import os
import gradio as gr
from mailparser import parse_from_string
def receive_mail(name):
email = parse_from_string(name)
return {
"Subject": email.subject,
"From": email.from_,
"To": email.to,
"Date": email.date,
"Message ID": email.message_id,
"Headers": email.headers,
"Attachments": email.attachments
}
def greet(name):
email_info = receive_mail(name)
formatted_output = ""
for key, value in email_info.items():
formatted_output += f"{key}: {value}\n"
return formatted_output
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()