Spaces:
Sleeping
Sleeping
Download email_agent.py from rohan131/Deep_Research: direct link, hf CLI and curl.
- Browser
- Download file 715 Bytes
-
https://huggingface.co/spaces/rohan131/Deep_Research/resolve/main/email_agent.py
- Command line
-
hf download hf://spaces/rohan131/Deep_Research/email_agent.py
-
curl -L -o email_agent.py https://huggingface.co/spaces/rohan131/Deep_Research/resolve/main/email_agent.py
715 Bytes
| import os | |
| from sendgrid import SendGridAPIClient | |
| from sendgrid.helpers.mail import Mail, Email, To, Content | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| SENDGRID_API_KEY = os.getenv("SENDGRID_API_KEY") | |
| def send_email(subject: str, html_body: str): | |
| sg = SendGridAPIClient(api_key=SENDGRID_API_KEY) | |
| from_email = Email("rohanmanuel2005@gmail.com") # Change as needed | |
| to_email = To("rohanmanuel2005@gmail.com") # Change as needed | |
| content = Content("text/html", html_body) | |
| mail = Mail(from_email, to_email, subject, content).get() | |
| response = sg.client.mail.send.post(request_body=mail) | |
| print("Email response:", response.status_code) | |
| return {"status": "success"} | |