📋 Configuração no Azure — passo a passo
1.
portal.azure.com →
Azure Active Directory →
App registrations →
New registration
2. Anote o Application (client) ID e o Directory (tenant) ID
3. Certificates & secrets → New client secret → anote o valor
4. API permissions → APIs my organization uses → Office 365 Exchange Online → Application → SMTP.SendAsApp
5. Clique em "Grant admin consent for [tenant]"
⚠️ Após o passo 5, execute no PowerShell (uma vez por caixa de correio):
Connect-ExchangeOnline -UserPrincipalName admin@empresa.com
New-ServicePrincipal -AppId CLIENT_ID -ServiceId OBJECT_ID
Add-MailboxPermission -Identity "envio@empresa.com" -User OBJECT_ID -AccessRights FullAccess
O Object ID está em: App registrations → seu app → Overview → "Object ID"
📧 Remetente
🔑 Credenciais Azure