Configuration

To configure a mailer for your application, you need to choose a backend and then specify any necessary configuration values for it. The following backends are provided out of the box:

Other backends may be provided by other components.

Once you’ve selected a backend, see its specific documentation to find out what configuration values you need to provide, if any. Configuration values are expressed as constructor arguments for the backend class:

components:
  mailer:
    backend: smtp
    host: primary-smtp.company.com
    username: foo
    password: bar

This configuration uses primary-smtp.company.com as the server hostname. Because it has a user name and password defined, the mailer will automatically use port 587 and STARTTLS before authenticating itself with the server.

The above configuration can be done directly in Python code as follows:

class ApplicationComponent(ContainerComponent):
    async def start(ctx: Context):
        self.add_component(
            'mailer', backend='smtp', host='primary-smtp.company.com', username='foo',
            password='bar')
        await super().start()

Multiple mailers

If you need to configure multiple mailers, you will need to use multiple instances of the mailer component:

.. code-block:: yaml
components:
mailer:

backend: smtp host: primary-smtp.company.com username: foo password: dummypass

mailer2:

type: mailer backend: sendmail

The above configuration creates two mailer resources: mailer and mailer2.