updated services api

This commit is contained in:
2025-05-30 23:43:46 +03:00
parent e5829f0525
commit f8184246d9
31 changed files with 2963 additions and 9 deletions

View File

@@ -0,0 +1,29 @@
from send_email import EmailService, EmailSendModel
# Create email parameters
email_params = EmailSendModel(
subject="Test Email",
html="<p>Hello world!</p>",
receivers=["recipient@example.com"],
text="Hello world!",
)
another_email_params = EmailSendModel(
subject="Test Email2",
html="<p>Hello world!2</p>",
receivers=["recipient@example.com"],
text="Hello world!2",
)
# The context manager handles connection errors
with EmailService.new_session() as email_session:
# Send email - any exceptions here will propagate up
EmailService.send_email(email_session, email_params)
# Or send directly through the session
email_session.send(email_params)
# Send more emails in the same session if needed
EmailService.send_email(email_session, another_email_params)