Skip to content

email

konigle.managers.comm.email

Email managers for the Konigle SDK.

This module provides manager classes for email accounts, channels, identities, and email operations with complete CRUD support.

AsyncEmailAccountManager

Bases: BaseEmailAccountManager, BaseAsyncManager

Asynchronous manager for email account resources.

check_status() async

Check the status of the email account to ensure email sending is operational.

RETURNS DESCRIPTION
Dict[str, Any]

A dictionary containing the status information of the email account.

Example:

status = await client.email_accounts.check_status()
print(f"Email account status: {status}")

create(data) async

Create a new email account.

PARAMETER DESCRIPTION
data

Email account creation data including all required fields

TYPE: EmailAccountCreate

RETURNS DESCRIPTION
EmailAccount

Created email account instance with Active Record capabilities

Example
account_data = EmailAccountCreate(
    name="Marketing Account",
    default_from_email="noreply@example.com",
    default_from_name="Example Team",
)
account = await client.email_accounts.create(account_data)
print(f"Created account: {account.name}")

setup(data) async

Set up a new email account along with its default channel and identity. Args: data: Email account setup data including all required fields Returns: A dictionary containing the created email account, its default channel, and identity. Example:

setup_data = EmailAccountSetup(
    name="Marketing Account",
    default_from_email=""
    default_reply_to_email=""
    identity_value="example.com",
)
setup_result = await client.email_accounts.setup(setup_data)
account = setup_result["account"]
channel = setup_result["channels"][0]
identity = setup_result["identity"]

AsyncEmailChannelManager

Bases: BaseEmailChannelManager, BaseAsyncManager

Asynchronous manager for email channel resources.

create(data) async

Create a new email channel.

PARAMETER DESCRIPTION
data

Email channel creation data including all required fields

TYPE: EmailChannelCreate

RETURNS DESCRIPTION
EmailChannel

Created email channel instance with Active Record capabilities

Example
channel_data = EmailChannelCreate(
    code="transactional",
    channel_type=EmailChannelType.TRANSACTIONAL,
)
channel = await client.email_channels.create(channel_data)
print(f"Created channel: {channel.code}")

set_engagement_tracking(channel_id, enable) async

Enable or disable engagement tracking for the channel.

PARAMETER DESCRIPTION
channel_id

ID of the channel to update

TYPE: str

enable

True to enable engagement tracking, False to disable

TYPE: bool

RETURNS DESCRIPTION
EmailChannel

Updated channel instance with engagement tracking setting

Example
channel = await client.email_channels.set_engagement_tracking(
    "ch_123", True
)
print(f"Engagement tracking: {channel.enable_engagement_tracking}")

AsyncEmailIdentityManager

Bases: BaseEmailIdentityManager, BaseAsyncManager

Asynchronous manager for email identity resources.

check_verification_status(identity_id) async

Check verification status for an email identity.

PARAMETER DESCRIPTION
identity_id

ID of the identity to verify

TYPE: str

Returns: Updated identity instance with verification status Example:

identity = await client.email_identities.check_verification_status("eid_123")
print(f"Verification status: {identity.verified}")

create(data) async

Create a new email identity.

PARAMETER DESCRIPTION
data

Email identity creation data including all required fields

TYPE: EmailIdentityCreate

RETURNS DESCRIPTION
EmailIdentity

Created email identity instance with Active Record capabilities

Example
identity_data = EmailIdentityCreate(
    identity_value="example.com",
)
identity = await client.email_identities.create(identity_data)
print(f"Created identity: {identity.identity_value}")

setup_custom_mail_from(identity_id, mail_from_domain) async

Setup custom MAIL FROM domain for an email identity. Args: identity_id: ID of the identity to setup custom MAIL FROM mail_from_domain: Custom MAIL FROM domain to be set Returns: Updated identity instance with custom MAIL FROM domain that is pending verification. The returned instance includes the dns records that need to be added for verification.

AsyncEmailManager

Bases: BaseEmailManager

Asynchronous manager for email operations.

Provides async functionality for sending emails and other email-related actions that don't involve resource management.

send(data) async

Send an email through the Konigle email service.

PARAMETER DESCRIPTION
data

Email data model instance or dict containing email details

TYPE: Union[Email, dict]

RETURNS DESCRIPTION
EmailResponse

SendEmailResponse with success message and optional IDs

Example
from konigle.models.comm import Email

email_data = Email(
    to_email=["recipient@example.com"],
    subject="Welcome to Konigle",
    body_html="<h1>Welcome!</h1><p>Thanks for signing up.</p>",
    body_text="Welcome! Thanks for signing up.",
    channel="welcome-emails",
    save_as_template=False
)

response = await client.emails.send(email_data)
print(f"Email sent: {response.message}")

AsyncEmailTemplateManager

Bases: BaseEmailTemplateManager, BaseAsyncManager

Asynchronous manager for email template resources.

create(data) async

Create a new email template.

PARAMETER DESCRIPTION
data

Email template creation data including all required fields

TYPE: EmailTemplateCreate

RETURNS DESCRIPTION
EmailTemplate

Created email template instance with Active Record capabilities

Example
template_data = EmailTemplateCreate(
    name="Welcome Email",
    code="welcome-email",
    subject="Welcome to {{company_name}}!",
    body_html="<h1>Welcome!</h1><p>Thanks for joining.</p>",
    body_text="Welcome! Thanks for joining.",
    tags=["welcome", "onboarding"]
)
template = await client.email_templates.create(template_data)
print(f"Created template: {template.name}")

EmailAccountManager

Bases: BaseEmailAccountManager, BaseSyncManager

Synchronous manager for email account resources.

check_status()

Check the status of the email account to ensure email sending is operational.

RETURNS DESCRIPTION
Dict[str, Any]

A dictionary containing the status information of the email account.

Example
status = client.email_accounts.check_status()
print(f"Email account status: {status}")

create(data)

Create a new email account.

PARAMETER DESCRIPTION
data

Email account creation data including all required fields

TYPE: EmailAccountCreate

RETURNS DESCRIPTION
EmailAccount

Created email account instance with Active Record capabilities

Example
account_data = EmailAccountCreate(
    name="Marketing Account",
    default_from_email="noreply@example.com",
    default_from_name="Example Team",
)
account = client.email_accounts.create(account_data)
print(f"Created account: {account.name}")

setup(data)

Set up a new email account along with its default channel and identity. Args: data: Email account setup data including all required fields Returns: A dictionary containing the created email account, its default channel, and identity. Example:

setup_data = EmailAccountSetup(
    name="Marketing Account",
    default_from_email=""
    default_reply_to_email=""
    identity_value="example.com",
)
setup_result = client.email_accounts.setup(setup_data)
account = setup_result["account"]
channel = setup_result["channels"][0]
identity = setup_result["identity"]

EmailChannelManager

Bases: BaseEmailChannelManager, BaseSyncManager

Synchronous manager for email channel resources.

create(data)

Create a new email channel.

PARAMETER DESCRIPTION
data

Email channel creation data including all required fields

TYPE: EmailChannelCreate

RETURNS DESCRIPTION
EmailChannel

Created email channel instance with Active Record capabilities

Example
channel_data = EmailChannelCreate(
    code="transactional",
    channel_type=EmailChannelType.TRANSACTIONAL,
)
channel = client.email_channels.create(channel_data)
print(f"Created channel: {channel.code}")

set_engagement_tracking(channel_id, enable)

Enable or disable engagement tracking for the channel.

PARAMETER DESCRIPTION
channel_id

ID of the channel to update

TYPE: str

enable

True to enable engagement tracking, False to disable

TYPE: bool

RETURNS DESCRIPTION
EmailChannel

Updated channel instance with engagement tracking setting

Example
channel = client.email_channels.set_engagement_tracking(
    "ch_123", True
)
print(f"Engagement tracking: {channel.enable_engagement_tracking}")

EmailIdentityManager

Bases: BaseEmailIdentityManager, BaseSyncManager

Synchronous manager for email identity resources.

check_verification_status(identity_id)

Check verification status for an email identity.

PARAMETER DESCRIPTION
identity_id

ID of the identity to verify

TYPE: str

RETURNS DESCRIPTION
EmailIdentity

Updated identity instance with verification status

Example
identity = client.email_identities.check_verification_status("eid_123")
print(f"Verification status: {identity.verified}")

create(data)

Create a new email identity.

PARAMETER DESCRIPTION
data

Email identity creation data including all required fields

TYPE: EmailIdentityCreate

RETURNS DESCRIPTION
EmailIdentity

Created email identity instance with Active Record capabilities

Example
identity_data = EmailIdentityCreate(
    identity_value="example.com",
)
identity = client.email_identities.create(identity_data)
print(f"Created identity: {identity.identity_value}")

setup_custom_mail_from(identity_id, mail_from_domain)

Setup custom MAIL FROM domain for an email identity.

PARAMETER DESCRIPTION
identity_id

ID of the identity to setup custom MAIL FROM

TYPE: str

mail_from_domain

Custom MAIL FROM domain to be set

TYPE: str

Returns: Updated identity instance with custom MAIL FROM domain that is pending verification. The returned instance includes the dns records that need to be added for verification.

EmailManager

Bases: BaseEmailManager

Synchronous manager for email operations.

Provides functionality for sending emails and other email-related actions that don't involve resource management.

send(data)

Send an email through the Konigle email service.

PARAMETER DESCRIPTION
data

Email data model instance or dict containing email details

TYPE: Union[Email, dict]

RETURNS DESCRIPTION
EmailResponse

SendEmailResponse with success message and optional IDs

Example
from konigle.models.comm import Email

email_data = Email(
    to_email=["recipient@example.com"],
    subject="Welcome to Konigle",
    body_html="<h1>Welcome!</h1><p>Thanks for signing up.</p>",
    body_text="Welcome! Thanks for signing up.",
    channel="welcome-emails",
    save_as_template=False
)

response = client.emails.send(email_data)
print(f"Email sent: {response.message}")

EmailTemplateManager

Bases: BaseEmailTemplateManager, BaseSyncManager

Synchronous manager for email template resources.

create(data)

Create a new email template.

PARAMETER DESCRIPTION
data

Email template creation data including all required fields

TYPE: EmailTemplateCreate

RETURNS DESCRIPTION
EmailTemplate

Created email template instance with Active Record capabilities

Example
template_data = EmailTemplateCreate(
    name="Welcome Email",
    code="welcome-email",
    subject="Welcome to {{company_name}}!",
    body_html="<h1>Welcome!</h1><p>Thanks for joining.</p>",
    body_text="Welcome! Thanks for joining.",
    tags=["welcome", "onboarding"]
)
template = client.email_templates.create(template_data)
print(f"Created template: {template.name}")