EmailFactory
What it is
- A small factory for creating
EmailServiceinstances configured with an SMTP adapter.
Public API
EmailFactory.EmailServiceSMTP(...) -> EmailService- Creates an
EmailServicewired toSMTPAdapterwith the provided SMTP connection settings.
- Creates an
Configuration/Dependencies
- Depends on:
naas_abi_core.services.email.EmailService.EmailServicenaas_abi_core.services.email.adapters.secondary.SMTPAdapter.SMTPAdapter
- Parameters:
host: str— SMTP server hostnameport: int— SMTP server portusername: str | None = None— optional usernamepassword: str | None = None— optional passworduse_tls: bool = False— enable STARTTLS (if supported by adapter/server)use_ssl: bool = False— enable SSL/TLS from connection starttimeout: int = 10— connection timeout in seconds (passed to adapter)
Usage
from naas_abi_core.services.email.EmailFactory import EmailFactory
email_service = EmailFactory.EmailServiceSMTP(
host="smtp.example.com",
port=587,
username="user",
password="secret",
use_tls=True,
timeout=10,
)
# Use email_service according to EmailService's API.
Caveats
use_tlsanduse_sslare both exposed; ensure you set them consistently with your SMTP server expectations.