---
title: Charmhub | Deploy SMTP Integrator using Charmhub - The Open Operator Collection
description: Deploy the latest version of SMTP Integrator on any cloud.
url: https://charmhub.io/smtp-integrator/libraries/smtp
---

# SMTP Integrator

[Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

* [Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

Platform:

26.04

24.04

22.04

stable 121

```
juju deploy smtp-integrator
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/smtp-integrator/libraries/smtp#drawer)

## charms.smtp\_integrator.v0.smtp

* [*Docstrings*Docstrings](https://charmhub.io/smtp-integrator/libraries/smtp)
  [*Code*Source code](https://charmhub.io/smtp-integrator/libraries/smtp/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.smtp_integrator.v0.smtp
    ```

    [Download smtp.py](https://charmhub.io/smtp-integrator/libraries/smtp/download)
  + *Last updated* 27 Jan 2026
  + *Revision* Library version 0.21

Library to manage the integration with the SMTP Integrator charm.

This library contains the Requires and Provides classes for handling the integration
between an application and a charm providing the `smtp` and `smtp-legacy` integrations.
If the requirer charm supports secrets, the preferred approach is to use the `smtp`
relation to leverage them.
This library also contains a `SmtpRelationData` class to wrap the SMTP data that will
be shared via the integration.

###### Requirer Charm

```
from charms.smtp_integrator.v0.smtp import SmtpDataAvailableEvent, SmtpRequires

class SmtpRequirerCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.smtp = smtp.SmtpRequires(self)
        self.framework.observe(self.smtp.on.smtp_data_available, self._handler)
        ...

    def _handler(self, events: SmtpDataAvailableEvent) -> None:
        ...
```

As shown above, the library provides a custom event to handle the scenario in
which new SMTP data has been added or updated.

###### Provider Charm

Following the previous example, this is an example of the provider charm.

```
from charms.smtp_integrator.v0.smtp import SmtpProvides

class SmtpProviderCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.smtp = SmtpProvides(self)
        ...
```

The SmtpProvides object wraps the list of relations into a `relations` property
and provides an `update_relation_data` method to update the relation data by passing
a `SmtpRelationData` data object.

```
class SmtpProviderCharm(ops.CharmBase):
    ...

    def _on_config_changed(self, _) -> None:
        for relation in self.model.relations[self.smtp.relation_name]:
            self.smtp.update_relation_data(relation, self._get_smtp_data())
```

---

Index

* [def recipients\_validator(
  )](https://charmhub.io/smtp-integrator/libraries/smtp#recipients_validator)
* [class SmtpError](https://charmhub.io/smtp-integrator/libraries/smtp#smtperror)
* [class SecretError](https://charmhub.io/smtp-integrator/libraries/smtp#secreterror)
* [class TransportSecurity](https://charmhub.io/smtp-integrator/libraries/smtp#transportsecurity)
* [class AuthType](https://charmhub.io/smtp-integrator/libraries/smtp#authtype)
* [class SmtpRelationData](https://charmhub.io/smtp-integrator/libraries/smtp#smtprelationdata)
* + [def to\_relation\_data(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtprelationdata-to_relation_data)
* [class SmtpDataAvailableEvent](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent)
* + [def host(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-host)
* + [def port(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-port)
* + [def user(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-user)
* + [def password(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-password)
* + [def password\_id(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-password_id)
* + [def auth\_type(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-auth_type)
* + [def transport\_security(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-transport_security)
* + [def domain(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-domain)
* + [def skip\_ssl\_verify(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-skip_ssl_verify)
* + [def smtp\_sender(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-smtp_sender)
* + [def recipients(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpdataavailableevent-recipients)
* [class SmtpRequiresEvents](https://charmhub.io/smtp-integrator/libraries/smtp#smtprequiresevents)
* [class SmtpRequires](https://charmhub.io/smtp-integrator/libraries/smtp#smtprequires)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/smtp-integrator/libraries/smtp#smtprequires-__init__)
* + [def get\_relation\_data(
    self)](https://charmhub.io/smtp-integrator/libraries/smtp#smtprequires-get_relation_data)
* + [def get\_relation\_data\_from\_relation(
    self,
    relation)](https://charmhub.io/smtp-integrator/libraries/smtp#smtprequires-get_relation_data_from_relation)
* [class SmtpProvides](https://charmhub.io/smtp-integrator/libraries/smtp#smtpprovides)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpprovides-__init__)
* + [def update\_relation\_data(
    self,
    relation,
    smtp\_data)](https://charmhub.io/smtp-integrator/libraries/smtp#smtpprovides-update_relation_data)
* [def parse\_recipients(
  raw
  )](https://charmhub.io/smtp-integrator/libraries/smtp#parse_recipients)

#### def recipients\_validator()

Return the correct recipients validator decorator for pydantic v1/v2.

Returns

A decorator to validate/normalize the recipients field before EmailStr validation.

#### class SmtpError

Description

Common ancestor for Smtp related exceptions. None

#### class SecretError

Description

Common ancestor for Secrets related exceptions. None

#### class TransportSecurity

Represent the transport security values.

Attributes

NONE

none

STARTTLS

starttls

TLS

tls

#### class AuthType

Represent the auth type values.

Attributes

NONE

none

NOT\_PROVIDED

not\_provided

PLAIN

plain

#### class SmtpRelationData

Represent the relation data.

Attributes

host

The hostname or IP address of the outgoing SMTP relay.

port

The port of the outgoing SMTP relay.

user

The SMTP AUTH user to use for the outgoing SMTP relay.

password

The SMTP AUTH password to use for the outgoing SMTP relay.

password\_id

The secret ID where the SMTP AUTH password for the SMTP relay is stored.

auth\_type

The type used to authenticate with the SMTP relay.

transport\_security

The security protocol to use for the outgoing SMTP relay.

domain

The domain used by the emails sent from SMTP relay.

skip\_ssl\_verify

Specifies if certificate trust verification is skipped in the SMTP relay.

smtp\_sender

Optional sender email address for outgoing notifications.

recipients

List of recipient email addresses for notifications.

Methods

SmtpRelationData.
to\_relation\_data(

*self*
)

Convert an instance of SmtpRelationData to the relation representation.

Returns

Dict containing the representation.

#### class SmtpDataAvailableEvent

Smtp event emitted when relation data has changed.

Attributes

host

The hostname or IP address of the outgoing SMTP relay.

port

The port of the outgoing SMTP relay.

user

The SMTP AUTH user to use for the outgoing SMTP relay.

password

The SMTP AUTH password to use for the outgoing SMTP relay.

password\_id

The secret ID where the SMTP AUTH password for the SMTP relay is stored.

auth\_type

The type used to authenticate with the SMTP relay.

transport\_security

The security protocol to use for the outgoing SMTP relay.

domain

The domain used by the emails sent from SMTP relay.

skip\_ssl\_verify

Specifies if certificate trust verification is skipped in the SMTP relay.

smtp\_sender

Optional sender email address for outgoing notifications.

recipients

List of recipient email addresses for notifications.

Methods

SmtpDataAvailableEvent.
host(

*self*
)

Description

Fetch the SMTP host from the relation. None

SmtpDataAvailableEvent.
port(

*self*
)

Description

Fetch the SMTP port from the relation. None

SmtpDataAvailableEvent.
user(

*self*
)

Description

Fetch the SMTP user from the relation. None

SmtpDataAvailableEvent.
password(

*self*
)

Description

Fetch the SMTP password from the relation. None

SmtpDataAvailableEvent.
password\_id(

*self*
)

Description

Fetch the SMTP password from the relation. None

SmtpDataAvailableEvent.
auth\_type(

*self*
)

Description

Fetch the SMTP auth type from the relation. None

SmtpDataAvailableEvent.
transport\_security(

*self*
)

Description

Fetch the SMTP transport security protocol from the relation. None

SmtpDataAvailableEvent.
domain(

*self*
)

Description

Fetch the SMTP domain from the relation. None

SmtpDataAvailableEvent.
skip\_ssl\_verify(

*self*
)

Description

Fetch the skip\_ssl\_verify flag from the relation. None

SmtpDataAvailableEvent.
smtp\_sender(

*self*
)

Fetch the SMTP sender from the relation.

Returns

smtp\_sender

Optional sender email address for outgoing notifications.

SmtpDataAvailableEvent.
recipients(

*self*
)

Fetch the SMTP recipients from the relation.

Returns

recipients

list of recipient email addresses for notifications.

#### class SmtpRequiresEvents

SMTP events.

Attributes

smtp\_data\_available

the SmtpDataAvailableEvent.

Description

This class defines the events that a SMTP requirer can emit.

#### class SmtpRequires

Requirer side of the SMTP relation.

Attributes

on

events the provider can emit.

Methods

SmtpRequires.
\_\_init\_\_(

*self*

,
charm

,
relation\_name: str
)

Construct.

Arguments

charm

the provider charm.

relation\_name

the relation name.

SmtpRequires.
get\_relation\_data(

*self*
)

Retrieve the relation data.

Returns

SmtpRelationData

the relation data.

SmtpRequires.
get\_relation\_data\_from\_relation(

*self*

,
relation
)

Retrieve the relation data.

Arguments

relation

the relation to retrieve the data from.

Returns

SmtpRelationData

the relation data.

#### class SmtpProvides

Description

Provider side of the SMTP relation. None

Methods

SmtpProvides.
\_\_init\_\_(

*self*

,
charm

,
relation\_name: str
)

Construct.

Arguments

charm

the provider charm.

relation\_name

the relation name.

SmtpProvides.
update\_relation\_data(

*self*

,
relation

,
smtp\_data: SmtpRelationData
)

Update the relation data.

Arguments

relation

the relation for which to update the data.

smtp\_data

a SmtpRelationData instance wrapping the data to be updated.

#### def parse\_recipients(raw: Any)

Normalize SMTP recipient input into a list of email strings.

Arguments

raw

Recipient input as received from relation data, charm config,
May be None, str, or list.

Returns

A list of recipient strings. The email correctness is validated later by EmailStr.

Description

The function produces a normalized list[str] so that downstream validation (EmailStr)
can be applied consistently.
