# microsoft/smtpoauth2 architecture

> Architecture diagram of the GitHub repository microsoft/smtpoauth2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/smtpoauth2
- Repository: https://github.com/microsoft/smtpoauth2

## Overview

This repository provides two administrator/developer tools: a PowerShell setup script for enabling SMTP OAuth in Exchange Online, and a Java client that obtains an app-only token, authenticates to SMTP, and optionally sends a test message. The Java flow is visible in the excerpt; the PowerShell implementation was not sampled, so its service relationships are documented but unverified.

Main entry points: [`java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`](https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java) (Test client CLI), [`ps/setupOAuth.ps1`](https://github.com/microsoft/smtpoauth2/blob/main/ps/setupOAuth.ps1) (Enable SMTP OAuth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["OAuth setup"]
  node_setup_script["Enable SMTP OAuth<br/>[setupOAuth.ps1]"]
end

subgraph group_token["Token acquisition"]
  node_java_client["Test client CLI"]
  node_token_request["Request access token"]
end

subgraph group_smtp["SMTP test"]
  node_smtp_auth["Authenticate to SMTP"]
  node_compose_message["Compose test message"]
  node_smtp_send["Send test email"]
end

node_operator(("Administrator or developer"))
node_entra["Microsoft Entra"]
node_exchange["Exchange Online"]
node_recipient(("Optional recipient"))

node_operator -->|"runs setup"| node_setup_script
node_setup_script -.->|"configures OAuth"| node_entra
node_setup_script -.->|"enables SMTP OAuth"| node_exchange
node_operator -->|"provides credentials"| node_java_client
node_java_client -->|"requests token"| node_token_request
node_token_request -->|"requests token"| node_entra
node_java_client -->|"connects with token"| node_smtp_auth
node_smtp_auth -->|"authenticates"| node_exchange
node_java_client -->|"creates message"| node_compose_message
node_operator -->|"selects recipient"| node_recipient
node_java_client -->|"sends message"| node_smtp_send
node_compose_message -->|"supplies message"| node_smtp_send
node_recipient -->|"receives email"| node_smtp_send

click node_setup_script "https://github.com/microsoft/smtpoauth2/blob/main/ps/setupOAuth.ps1"
click node_java_client "https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java"
click node_token_request "https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java"
click node_smtp_auth "https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java"
click node_compose_message "https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java"
click node_smtp_send "https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_setup_script toneBlue
class node_java_client,node_token_request toneAmber
class node_smtp_auth,node_compose_message,node_smtp_send toneMint
class node_operator,node_entra,node_exchange,node_recipient toneIndigo
```

## Components

### OAuth setup

- [Enable SMTP OAuth](https://github.com/microsoft/smtpoauth2/blob/main/ps/setupOAuth.ps1): `ps/setupOAuth.ps1`

### Token acquisition

- [Test client CLI](https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java): `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`
- [Request access token](https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java): `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`

### SMTP test

- [Authenticate to SMTP](https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java): `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`
- [Compose test message](https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java): `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`
- [Send test email](https://github.com/microsoft/smtpoauth2/blob/main/java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java): `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`

### Other components

- **Administrator or developer**
- **Microsoft Entra**
- **Exchange Online**
- **Optional recipient**

## Connections

- Administrator or developer → Enable SMTP OAuth: runs setup (evidence: `README.md`)
- Enable SMTP OAuth → Microsoft Entra: configures OAuth
- Enable SMTP OAuth → Exchange Online: enables SMTP OAuth
- Administrator or developer → Test client CLI: provides credentials (evidence: `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`)
- Test client CLI → Request access token: requests token (evidence: `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`)
- Request access token → Microsoft Entra: requests token (evidence: `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`)
- Test client CLI → Authenticate to SMTP: connects with token (evidence: `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`)
- Authenticate to SMTP → Exchange Online: authenticates (evidence: `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`)
- Test client CLI → Compose test message: creates message (evidence: `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`)
- Administrator or developer → Optional recipient: selects recipient
- Test client CLI → Send test email: sends message (evidence: `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`)
- Compose test message → Send test email: supplies message (evidence: `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`)
- Optional recipient → Send test email: receives email (evidence: `java/src/main/java/com/microsoft/smtpoauth/SMPTOAuth2Test.java`)
