domain.protocols.email_protocol¶
src.domain.protocols.email_protocol
¶
EmailProtocol - Port for email service implementations.
Defines the interface for sending emails in the application. Infrastructure layer provides concrete implementations (StubEmailService, AWSEmailService).
Classes¶
EmailProtocol
¶
Bases: Protocol
Email service protocol (port).
Defines the interface for email operations. Infrastructure layer provides concrete implementations.
This is a Protocol (not ABC) for structural typing. Implementations don't need to inherit from this.
Methods:
| Name | Description |
|---|---|
send_verification_email |
Send email verification link |
send_password_reset_email |
Send password reset link |
send_password_changed_notification |
Notify user of password change |
Example Implementation
class StubEmailService: ... async def send_verification_email( ... self, ... to_email: str, ... verification_url: str, ... ) -> None: ... # Log to console ... print(f"[STUB] Verification email to {to_email}")
Source code in src/domain/protocols/email_protocol.py
Functions¶
send_verification_email
async
¶
Send email verification link to user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_email
|
str
|
Recipient email address. |
required |
verification_url
|
str
|
Full URL with verification token. |
required |
Example
await email_service.send_verification_email( ... to_email="user@example.com", ... verification_url="https://app.com/verify?token=abc123", ... )
Source code in src/domain/protocols/email_protocol.py
send_password_reset_email
async
¶
Send password reset link to user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_email
|
str
|
Recipient email address. |
required |
reset_url
|
str
|
Full URL with password reset token. |
required |
Example
await email_service.send_password_reset_email( ... to_email="user@example.com", ... reset_url="https://app.com/reset?token=xyz789", ... )
Source code in src/domain/protocols/email_protocol.py
send_password_changed_notification
async
¶
Send notification that password was changed.
Security notification to alert user of password change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_email
|
str
|
Recipient email address. |
required |
Example
await email_service.send_password_changed_notification( ... to_email="user@example.com", ... )