Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@ subject = Default SMTP Subject
> * SMTP **supports** attachments and will include them in the outbound message.
> * MS365 **ignores** attachments (you’ll see a warning in the logs if you pass any).
> * All email templates must live under `/Templates/Email/`.
> * If both SMTP and MS365 are configured, SMTP will be used as the default mail transport.

---

### ⚙️ How Microsoft 365 Email Works

When **MS365** is configured, Iris sends emails through the **Microsoft Graph API** instead of SMTP.
It uses **OAuth2 client-credentials flow** to authenticate using your Azure app credentials.

**Flow summary:**

1. Reads the `[m365_email]` configuration.
2. Initializes an MSAL client with your `tenant_id`, `client_id`, and `client_secret`.
3. Obtains an access token for the scope `https://graph.microsoft.com/.default`.
4. Sends the message via `POST https://graph.microsoft.com/v1.0/users/{user_email}/sendMail`.
5. Supports HTML body, CC/BCC, and inline base64-encoded attachments.

**Transport selection logic:**

* If **only `[m365_email]`** is configured → MS365 is used.
* If **only `[smtp]`** is configured → SMTP is used.
* If **both** are configured → **SMTP takes priority** and will be used as the default transport.
* If **neither** is configured → the `/send_email` API returns `400 Email service not configured.`

---

Expand Down