Spaces:
Sleeping
Sleeping
| from email.message import EmailMessage | |
| import aiosmtplib | |
| import os | |
| class EmailService: | |
| def __init__(self): | |
| pass | |
| async def send_test_email(self, recipient: str): | |
| try: | |
| message = EmailMessage() | |
| message["From"] = f"KittyKat Agents" | |
| message["To"] = recipient | |
| message["Subject"] = "Test Email from KittyKat Agents" | |
| message.set_content( | |
| "This is a test email to verify the email service is operational.") | |
| message.add_alternative("<h1>Test</h1>", subtype="html") | |
| await aiosmtplib.send( | |
| message, | |
| hostname="smtp.office365.com", | |
| port=587, | |
| username="noreply@kittykat.ai", | |
| password=os.getenv("EMAIL_PASSWORD"), | |
| start_tls=True | |
| # hostname="smtp.gmail.com", | |
| # port=587, | |
| # username="hariprasath137@gmail.com", | |
| # password=os.getenv("EMAIL_PASSWORD"), | |
| # start_tls=True | |
| ) | |
| except Exception as e: | |
| print(f"Error sending test email: {e}") | |
| raise e | |