EmailSenderProtocol
Protocol for email sending operations.
This is the PORT for sending emails.
Implementations (adapters) handle actual delivery.
Adapters:
- SMTPEmailSender: Send via SMTP server
- LogEmailSender: Log to console (development)
- ExternalServiceSender: Via notification service
Example:
sender: EmailSenderProtocol = container.email_sender()
result = await sender.send(EmailMessage(...))
Source: email_sender.py
Methods
send
async def send(self, message: EmailMessage) -> SendResult
Send an email message.
Args:
message: Email message to send
Returns:
SendResult with success status
Raises:
EmailSendError: If sending fails
is_available
async def is_available(self) -> bool
Check if the sender is available.
Returns:
True if ready to send, False otherwise