Connection

A connection is one live link a backend opened, for many sends until it closes for good.

Usage

Source

Connection(
    backend,
    transport,
)

Build one with Backend.connect(). It belongs to one thread and one with, and never reopens. It checks each message and builds the submission and the send result, so a third-party backend writes only a Transport. See ADR-0005.

Attributes

backend: Backend
The backend that opened this connection.

Methods

Name Description
__enter__() Return this connection, which connect() already opened.
__exit__() Close the connection, suppressing nothing.
close() Close the link for good.
send() Check message, submit it, and build the send result.

__enter__()

Return this connection, which connect() already opened.

Usage

Source

__enter__()
Raises
ValueError
When the connection is closed.

__exit__()

Close the connection, suppressing nothing.

Usage

Source

__exit__(*exc_info)

close()

Close the link for good.

Usage

Source

close()

It is idempotent and never raises, so __exit__ never replaces an error from the with body. See ADR-0005.


send()

Check message, submit it, and build the send result.

Usage

Source

send(message)

When the service refuses some recipients and accepts the rest, the send raises nothing and SendResult.refused holds the refusals.

Raises
ValueError

When the connection is closed, when the message names no recipient, or when an <img src> names a cid: that no inline image holds. When a Message-ID cannot hold the from address’s domain, such as a domain with an empty label. See ADR-0015.

RecipientsRefusedError

When the service refused every recipient.

EpistoleError
The error the transport raised, with backend set.