Send Email and Notifications on Autonomous AI Database
There are a number of options for sending email on Autonomous AI Database. You can also send notifications to a Slack channel, to MSTeams, or to an OCI Notifications topic.
- Send Email on Autonomous AI Database
There are a number of options for sending email on Autonomous AI Database. You can also send text messages or the output of an SQL query to a Slack or MSTeams channel. - Send Slack Notifications from Autonomous AI Database
Describes how to configure Slack so that you can send messages, alerts, or output of a query from Autonomous AI Database to a Slack Channel. Also describes the procedures you use to send Slack notifications. - Send Messages to OCI Notifications Service from Autonomous AI Database
Describes how to send messages from Autonomous AI Database to an OCI Notifications service topic. - Send Email from Autonomous AI Database with Microsoft Exchange using OAuth2
Oracle Autonomous AI Database supports sending email through Microsoft Exchange by leveraging OAuth 2.0. - Send Microsoft Teams Notifications from Autonomous AI Database
Describes how to configure Microsoft Teams so that you can send messages, alerts, or output of a query from Autonomous AI Database to a Microsoft Teams Channel. Also describes the procedures you use to send Microsoft Teams notifications.
Parent topic: Develop
Send Email from Autonomous AI Database with Microsoft Exchange using OAuth2
Oracle Autonomous AI Database supports sending email through Microsoft Exchange by leveraging OAuth 2.0.
To use OAuth2, you first need to register an application in Azure, assign the correct API permissions, create a Secret for the App, and create a credential object in Autonomous AI Database. Once configured, you can send messages via DBMS_CLOUD_NOTIFICATION.
DBMS_CLOUD_NOTIFICATION:
- Register an application in Microsoft Entra (Azure AD):
In the Azure portal, create a new app registration and note the Application (client) ID and Azure Tenant ID. For details, see Microsoft’s guidance on registering an application.
- Create a Secret in Client credentials for the Application:
The client ID and the client secret are needed to create a secure credential object in your database that is used to identity your database as the registered application that can send emails.
- Add the "Mail.Send "permission and grant admin consent:
In Azure, under API permissions, add the Mail.Send application permission in Microsoft Graph and have an administrator grant consent.
Your environment is now set configured to send emails using the
DBMS_CLOUD_NOTIFICATIONpackage with any valid email account of your MS Exchange environment.
Sending email
Use DBMS_CLOUD_NOTIFICATION.SEND_MESSAGE with provider attribute set as email using a valid email account and your credential with the client ID or secret that was registered as trusted application to send email.
- You must create a credential that stores the client ID and secret:
BEGIN DBMS_CLOUD.CREATE_CREDENTIAL( credential_name => 'MS_TOKEN', username => '<client_id>', password => '<client_secret>' ); END; / - Send an email using the client credentials flow:
BEGIN DBMS_CLOUD_NOTIFICATION.SEND_MESSAGE( provider => 'email', credential_name => 'MS_TOKEN', message => 'Message content', params => json_object( 'recipient' value 'recipient@example.com', 'subject' value 'Test subject', 'smtp_host' value 'smtp.office365.com', 'sender' value 'sender@xyz.com', 'tenant' value '<azure_tenant_id>' ) ); END; /
Troubleshooting
- Port connectivity: SMTP connections require outbound TCP port 587. If you receive
ORA‑29278: SMTP transient error: 421 Service not available, verify that network ACLs allow outbound connections to smtp.office365.com:587. - Missing permissions: Authentication failures often occur when the application hasn’t been granted admin consent or when the service principal has not been registered in Exchange. Revisit the steps to grant permissions and register the service principal.
- SMTP AUTH disabled: If you cannot authenticate after obtaining tokens, ensure that
SMTP AUTHis enabled for the mailbox and not globally disabled.
-
- Microsoft documentation on [Authenticating IMAP, POP and SMTP using OAuthAuthenticating IMAP, POP and SMTP using OAuth].
- Microsoft Learn article on the [OAuth 2.0 authorization code flow].
- Microsoft Learn article on [Enabling or disabling SMTP AUTHEnabling or disabling SMTP AUTH].
Parent topic: Send Email and Notifications on Autonomous AI Database