Skip to content

Commit b5f7f45

Browse files
authored
Enhance sendmail.py documentation with usage details
Updated the sendmail.py section to provide detailed usage instructions, including environment variable setup and example command with parameters.
1 parent f248683 commit b5f7f45

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,28 @@ Use like so:
177177
---
178178
### `sendmail.py`
179179

180-
Send email impersonations, need "Mail.Send" permissions.
180+
Sends an authorized email through Microsoft Graph using app-only client-credentials authentication and the Mail.Send application permission. The script accepts configurable sender, recipient, subject, and message-body values, reads the application secret from an environment variable, supports a dry-run mode, and returns detailed Microsoft Graph errors without printing or storing access tokens.
181+
The Entra application must have the Microsoft Graph Mail.Send application permission with administrator consent. Because this permission can provide broad mail-sending capability, Exchange Online App RBAC should be used to restrict the application to approved sender mailboxes. An HTTP 202 Accepted response confirms that Microsoft Graph accepted the message for processing, but does not guarantee final delivery.
181182

182183
Use like so:
183-
`python .\sendmail.py`
184+
`$secureSecret = Read-Host "Enter the application client secret" -AsSecureString
185+
186+
$env:ENTRA_CLIENT_SECRET = [System.Net.NetworkCredential]::new(
187+
"",
188+
$secureSecret
189+
).Password
190+
191+
python .\send_graph_mail.py `
192+
--tenant-id "00000000-0000-0000-0000-000000000000" `
193+
--client-id "11111111-1111-1111-1111-111111111111" `
194+
--sender "notifications@contoso.com" `
195+
--recipient "analyst@contoso.com" `
196+
--subject "Microsoft Graph mail validation" `
197+
--body "This is an authorized app-only Microsoft Graph email test." `
198+
--acknowledge-authorized-mailbox `
199+
--dry-run
200+
`
201+
Send the message by removing --dry-run
184202

185203
---
186204
### `Get-AzureStorageAnonymousAccess.ps1`

0 commit comments

Comments
 (0)