s365b.notify.senders

Ways to send email: Microsoft Graph and SMTP.

Exceptions

SendError

Sending failed. The message is safe to show.

Classes

Notifier

Something that can send an email.

GraphNotifier

Sends as a mailbox through /users/{sender}/sendMail.

SmtpNotifier

Sends through an SMTP relay.

Module Contents

exception s365b.notify.senders.SendError[source]

Bases: Exception

Sending failed. The message is safe to show.

class s365b.notify.senders.Notifier[source]

Bases: Protocol

Something that can send an email.

name: str[source]
async send(message: s365b.notify.message.Message, recipients: list[str]) → None[source]

Send one message.

Parameters:
  • message – The message.

  • recipients – To addresses.

Raises:

SendError – If sending failed.

class s365b.notify.senders.GraphNotifier(graph: s365b.graph.client.GraphClient, sender: str)[source]

Sends as a mailbox through /users/{sender}/sendMail.

The Notifications app may send only as that mailbox: its Mail.Send is an Exchange RBAC assignment scoped to it, not a tenant-wide grant.

Parameters:
  • graph – Graph client authenticated as the Notifications app.

  • sender – Sender mailbox address.

name = 'graph'[source]
graph[source]
sender[source]
async send(message: s365b.notify.message.Message, recipients: list[str]) → None[source]

Send one message (not saved to Sent Items).

Parameters:
  • message – The message.

  • recipients – To addresses.

Raises:

SendError – If Graph refuses or cannot be reached.

class s365b.notify.senders.SmtpNotifier(host: str, port: int, security: str, sender: str, username: str = '', password: str = '', timeout: float = 30.0)[source]

Sends through an SMTP relay.

Parameters:
  • host – Relay host.

  • port – Port.

  • security – starttls, tls (implicit) or none.

  • sender – From address.

  • username – Login user; empty for none.

  • password – Login password.

  • timeout – Socket timeout in seconds.

name = 'smtp'[source]
timeout = 30.0[source]
async send(message: s365b.notify.message.Message, recipients: list[str]) → None[source]

Send one message.

Parameters:
  • message – The message.

  • recipients – To addresses.

Raises:

SendError – For connection, TLS, authentication or relay errors.