email_manager.py — sends notifications from a strategy script
through an account configured on the
Notifications page.
Quick usage
from quantstrip import send_email
send_email(
subject="Strategy alert",
body="Position limit reached for SPY.",
to="ops@yourfirm.com",
)
send_email is a module-level convenience function that sends through the
default account. For a named account, cc, or HTML body, use email_manager
directly.
EmailAccount
A dataclass representing one configured account:
@dataclass
class EmailAccount:
email_account_id: int
name: str
provider: str
smtp_server: str
smtp_port: int
use_tls: bool
username: str
password: str
from_address: str
from_name: str
is_default: bool = False
EmailManager
All configured accounts.
Dict[str, EmailAccount], keyed by account name.The account marked default, or the first available account if none is marked.
Optional[EmailAccount].Look up one account by name.
Optional[EmailAccount].Sends an email via SMTP through account (or the default account if omitted).
(success: bool, message: str).Sends a test email through the named account. Equivalent to the Notifications page's "test connection" action.
(success: bool, message: str).Programmatic account management, equivalent to the operations available from the Notifications page's UI.
secret-typed Settings values.