Core Python API
Functions
outgoing provides the following functions for constructing e-mail sender
objects. Once you have a sender object, simply use it in a context manager to
open it up, and then call its send() method with each
email.message.EmailMessage object you want to send. See Examples for
examples.
- outgoing.from_config_file(path: str | bytes | PathLike[str] | PathLike[bytes] | None = None, section: str | None = 'outgoing', fallback: bool = True) Sender[source]
Read configuration from the table/field
section(default “outgoing”) in the file atpath(default: the path returned byget_default_configpath()) and construct a sender object from the specification. The file may be either TOML or JSON (type detected based on file extension). IfsectionisNone, the entire file, rather than only a single field, is used as the configuration. Iffallbackis true, the file is not the default config file, and the file either does not exist or does not contain the given section, fall back to reading from the default section of the default config file.- Raises:
InvalidConfigError – if the configuration is invalid
MissingConfigError – if no configuration file or section is present
- outgoing.from_dict(data: Mapping[str, Any], configpath: str | bytes | PathLike[str] | PathLike[bytes] | None = None) Sender[source]
Construct a sender object using the given
dataas the configuration. Ifconfigpathis given, any paths in thedatawill be resolved relative toconfigpath’s parent directory; otherwise, they will be resolved relative to the current directory.datashould not contain a"configpath"key; such an entry will be discarded.- Raises:
InvalidConfigError – if the configuration is invalid
- outgoing.get_default_configpath() Path[source]
Returns the location of the default config file (regardless of whether it exists) as a
pathlib.Pathobject
Sender Objects
- class outgoing.Sender[source]
Senderis aProtocolimplemented by sender objects. The protocol requires the following behavior:Sender objects can be used as context managers, and their
__enter__methods returnself.Within its own context, calling a sender’s
send(msg: email.message.EmailMessage)method sends the given e-mail.
- __exit__(exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None) bool | None[source]
- send(msg: EmailMessage) Any[source]
Send
msgor raise an exception if that’s not possible
In addition to the base protocol, outgoing’s built-in senders are
reentrant and reusable as context managers, and their send() methods
can be called outside of a context.
Exceptions
- exception outgoing.Error[source]
Bases:
ExceptionThe superclass for all exceptions raised by
outgoing
- exception outgoing.InvalidConfigError(details: str, configpath: str | bytes | PathLike[str] | PathLike[bytes] | None = None)[source]
Bases:
ErrorRaised on encountering an invalid configuration structure
- exception outgoing.InvalidPasswordError(details: str, configpath: str | bytes | PathLike[str] | PathLike[bytes] | None = None)[source]
Bases:
InvalidConfigErrorRaised on encountering an invalid password specifier or when no password can be determined from a specifier
- exception outgoing.MissingConfigError(configpaths: Sequence[str | bytes | PathLike[str] | PathLike[bytes]])[source]
Bases:
ErrorRaised when no configuration section can be found in any config files
- exception outgoing.NetrcLookupError[source]
Bases:
ErrorRaised by
lookup_netrc()on failure to find a match in a netrc file