from send_email import EmailService, EmailSendModel # Create email parameters email_params = EmailSendModel( subject="Test Email", html="
Hello world!
", receivers=["recipient@example.com"], text="Hello world!", ) another_email_params = EmailSendModel( subject="Test Email2", html="Hello world!2
", 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)