Connecting to IMAP servers
Basic Connectivity
AlertMagic allows you to ingest emailed events via the IMAP protocol. To permit this, you first need to add an "IMAP Server" Connection.
Method 1: Authenticating with Username and Password
This is the standard method for authenticating with an IMAP server using basic authentication.
- In the URL field, enter your secure IMAP server in the form
imaps://<server>:<port> - Example:
imaps://imap.gmail.com:993 - You can change the server and port.
- You cannot change the protocol, as only secure connections are supported.
- Make sure there is no trailing slash.
- In the Username field:
- Enter your IMAP username.
- Usually the account's email address.
- In the Password field:
- Many providers, including Google, require that you create a dedicated application password.
- If you need this for Gmail, click here.
- In the Configuration field, you will typically add your AlertMagic Integration JSON (see "AlertMagic Integration" section below). No specific authentication parameters are added to this JSON for this method, as username/password are handled directly by the fields above.
Method 2: Authenticating with OAuth2 (Client Credentials Grant for Microsoft 365/Azure)
AlertMagic supports OAuth2 for IMAP connections specifically using the Client Credentials grant flow. This method is suitable for server-to-server authentication where AlertMagic needs to access a protected resource (reading emails) without a user present, and it requires registering an application in your email provider's identity system (e.g., Azure Active Directory for Microsoft 365).
This Microsoft documentation page provides general information - be sure to follow instructions for the IMAP Client Credentials grant flow. See below for full set-up instructions.
Important Note: The Client Credentials grant flow is primarily supported by Microsoft (Azure Active Directory) for service-to-server communication. Google (Gmail) does not support the Client Credentials grant flow for IMAP connections via their APIs. Therefore, AlertMagic's OAuth2 IMAP capability is currently limited to Microsoft 365/Azure environments.
- In the URL field, enter your secure IMAP server in the form
imaps://<server>:<port> - Example:
imaps://outlook.office365.com:993 - You can change the server and port.
- You cannot change the protocol, as only secure connections are supported.
- Make sure there is no trailing slash.
- In the User name field, enter the email address of the mailbox that the service account has permissions to access (e.g.,
reports@yourcompany.com). This is the identity for which AlertMagic will retrieve mail. - In the Password field, enter the Client Secret obtained from your application registration in Azure Active Directory.
- In the Configuration field, enter JSON that includes both the OAuth2 parameters and your AlertMagic Integration (if applicable). For example:
{ "GrantType":"ClientCredentials", "AuthType":"OAuth2", "ClientID": "YOUR_CLIENT_ID", "Scope":"https://outlook.office365.com/.default", "TokenUrl":"https://login.microsoftonline.com/YOUR_TENANT_ID/oauth2/v2.0/token", "ClientAuthType":"SendClientCredentialsInBody", "AlertMagic": { "Ingests": [ { "Name": "Knock Knock", "Uri": "https://pdl-alertmagic-production.azurewebsites.net/api/notify", "Username": "xxx", "Password": "yyy", "Filter": { "From": "^tri.+@zion.com$", "Subject": "^alert", "Body": "white.+rabbit" }, "Payload": { "FromCaptures": [ "^(?<from>.+)$" ], "SubjectCaptures": [ "^alert - (?<subject>.+)$" ], "BodyCaptures": [ "Spoon: (?<spoon>[^\n]+)", "Skills: (?<skills>[^\n]+)" ] }, "CleanUp": { "Action": "MoveToFolder", "Folder": "AlertMagic Processed", "DeleteAfterDays": 30 } } ] } }
Explanation of Configuration fields for OAuth2 (Client Credentials):
"GrantType": Must be set to"ClientCredentials"."AuthType": Must be set to"OAuth2"."ClientID": This is the Application (client) ID obtained from your application registration in Azure Active Directory."Scope": The permissions AlertMagic requires. For Microsoft 365,https://outlook.office365.com/.defaultis a common scope for reading mail on behalf of the application itself."TokenUrl": The OAuth2 token endpoint for your Microsoft 365 tenant. TheYOUR_TENANT_IDwill be your Azure AD Tenant ID (Directory ID)."ClientAuthType": Specifies how the client credentials (ClientID and ClientSecret) are sent to the token endpoint."SendClientCredentialsInBody"means they are sent in the request body.
AlertMagic Integration
AlertMagic can be configured to pick up emails from the IMAP server, parse them, repackage as JSON and send the results to AlertMagic. This is achieved using an "AlertMagic" node in the JSON configuration fields (as seen in the OAuth2 example above, or as the sole content of the Configuration field for Username/Password authentication). This is best illustrated with an example:
Incoming email:
From: trinity@zion.com
Subject: alert - Wake up Neo
Body:
Follow the white rabbit
Spoon: false
Skills: "Kung Fu", "Helicopter Pilot"
Configuration (example illustrating only the AlertMagic node):
{
"AlertMagic": {
"Ingests": [
{
"Name": "Knock Knock",
"Uri": "https://pdl-alertmagic-production.azurewebsites.net/api/notify",
"Username": "xxx",
"Password": "yyy",
"Filter": {
"From": "^tri.+@zion.com$",
"Subject": "^alert",
"Body": "white.+rabbit"
},
"Payload": {
"FromCaptures": [
"^(?<from>.+)$"
],
"SubjectCaptures": [
"^alert - (?<subject>.+)$"
],
"BodyCaptures": [
"Spoon: (?<spoon>[^\n]+)",
"Skills: (?<skills>[^\n]+)"
]
},
"CleanUp": {
"Action": "MoveToFolder",
"Folder": "AlertMagic Processed",
"DeleteAfterDays": 30
}
}
]
}
}
In this configuration example, incoming emails are only processed if they are from someone whose name starts with "tri", working for "zion.com". Next, the Subject line must start with the word alert and the Body must contain the words "white" and "rabbit" in that order. The text is scanned for the fields "Spoon" and "Skills".
The result would be a new WebHook, injected into AlertMagic's Integration with Id = 123, as follows:
{
"from": "trinity@zion.com",
"subject": "Wake up Neo",
"spoon": "false",
"skills": "\"Kung Fu\", \"Helicopter Pilot\""
}
Note that only string values are supported at present.
Configuring Azure AD for Magic Suite IMAP Access
Why OAuth for IMAP?
- ✓ No passwords stored - More secure than basic authentication
- ✓ Granular control - Restrict access to specific mailboxes only
- ✓ Auditable - Track when and how Magic Suite accesses your email
- ✓ Revocable - Disable access instantly without changing passwords
- ✓ Compliant - Meets modern security standards and compliance requirements
Magic Suite Application Details
- Application Name: Magic Suite
- Provider: Panoramic Data Limited
- Magic Suite Application (Client) ID:
eb6992c6-9e08-444d-be7d-17b490f2f3d3 - Required Permissions: Office 365 Exchange Online - IMAP.AccessAsApp
- Access Scope: Only mailboxes you explicitly grant access to
- Authentication Method: OAuth 2.0 Multi-Tenant Application
- You must be a Global Administrator or Application Administrator in your Azure AD tenant
- Your organization must have Microsoft 365 with Exchange Online
- PowerShell must be available for Exchange Online configuration
Configuration Steps
Step 1: Consent to Magic Suite Application
-
Initiate Admin Consent
Click the following admin consent URL (you must be logged in as a Global Administrator or Application Administrator):Or manually construct the URL with your specific tenant:https://login.microsoftonline.com/{YOUR_TENANT_ID}/v2.0/adminconsent?client_id=eb6992c6-9e08-444d-be7d-17b490f2f3d3&scope=https://outlook.office365.com/.default
-
Review Permissions
You will see a consent screen showing:
- Application: Magic Suite
- Publisher: Panoramic Data Limited
- Permissions requested:
- Access mailboxes via IMAP (IMAP.AccessAsApp)
-
Grant Admin Consent
Review the permissions carefullyCheck the box "Consent on behalf of your organization"Click "Accept"You should see a confirmation that permissions have been granted. The Magic Suite service principal is now registered in your tenant.
-
Verify the Application Registration (Optional)
Search for "Magic Suite" - you should see it listedClick on it and go to "Permissions" to verify the IMAP.AccessAsApp permission is granted
Step 2: Configure Exchange Online Access Policy
-
Install Exchange Online Management Module
Open PowerShell as Administrator
# Install the module (one-time setup)
Install-Module ExchangeOnlineManagement -Force -AllowClobber
# Import the module
Import-Module ExchangeOnlineManagement -
Connect to Exchange Online
# Connect to your Exchange Online environment
Connect-ExchangeOnline
# You will be prompted to sign in with your admin credentials -
Identify the Mailbox to Grant Access
Determine which mailbox(es) Magic Suite needs to access. This is typically a shared mailbox or service account that receives monitoring alerts, tickets, or notifications.Example mailboxes:
alerts@yourcompany.commonitoring@yourcompany.comservicedesk@yourcompany.com
Verify the mailbox exists:Get-Mailbox your-mailbox@yourcompany.com | Select-Object DisplayName, PrimarySmtpAddress -
Ensure IMAP is Enabled for the Mailbox
# Check current IMAP status
Get-CASMailbox your-mailbox@yourcompany.com | Select-Object ImapEnabled
# If IMAP is disabled, enable it:
Set-CASMailbox your-mailbox@yourcompany.com -ImapEnabled $true -
Create the Application Access Policy
This is the critical security step that restricts Magic Suite to ONLY the mailbox(es) you specify:
# Define the Magic Suite application ID
$appId = "eb6992c6-9e08-444d-be7d-17b490f2f3d3"
# Define your mailbox
$mailbox = "your-mailbox@yourcompany.com"
# Create the access policy
New-ApplicationAccessPolicy `
-AppId $appId `
-PolicyScopeGroupId $mailbox `
-AccessRight RestrictAccess `
-Description "Allow Magic Suite to access monitoring mailbox via IMAP"Note: TheRestrictAccessright means the application can ONLY access mailboxes listed in the policy. This is the most secure option. -
Verify the Configuration
# View the policy
Get-ApplicationAccessPolicy | Where-Object { $_.AppId -eq $appId } | Format-List
# Test that access is granted
Test-ApplicationAccessPolicy -Identity $mailbox -AppId $appIdExpected Result:
AccessCheckResult: Granted
If you see "Granted", the configuration is complete and working correctly! -
(Optional) Grant Access to Multiple Mailboxes
If Magic Suite needs to access multiple mailboxes, you have two options:Option A: Create a distribution group containing all mailboxes, then use the group in the policy
# Create a distribution group
New-DistributionGroup -Name "MagicSuiteAccessGroup" -Members mailbox1@yourcompany.com,mailbox2@yourcompany.com
# Use the group in the policy
New-ApplicationAccessPolicy -AppId $appId -PolicyScopeGroupId "MagicSuiteAccessGroup" -AccessRight RestrictAccessOption B: Create separate policies for each mailbox (simpler but more policies to manage)# Create individual policies
New-ApplicationAccessPolicy -AppId $appId -PolicyScopeGroupId "mailbox1@yourcompany.com" -AccessRight RestrictAccess
New-ApplicationAccessPolicy -AppId $appId -PolicyScopeGroupId "mailbox2@yourcompany.com" -AccessRight RestrictAccess
Step 3: Provide Configuration Details to Panoramic Data
| Information Needed | Where to Find It |
|---|---|
| Your Tenant ID | Azure Portal → Azure Active Directory → Overview → Tenant ID |
| Mailbox Email Address(es) | The email address(es) you configured in the access policy |
| Confirmation of Admin Consent | Confirm that you completed Step 1 successfully |
- Passwords for any user accounts
- Service principal secrets (not needed - Panoramic Data manages their own application credentials)
- Any other sensitive credentials
How Magic Suite Authenticates
- Magic Suite uses its own Azure AD application and credentials (managed by Panoramic Data) to authenticate
- When accessing your tenant, Magic Suite requests an OAuth token from Azure AD using the multi-tenant application flow
-
Azure AD verifies that:
- Your admin granted consent (Step 1)
- The requested mailbox is in your Application Access Policy (Step 2)
- The request comes from the legitimate Magic Suite application
- Only if all checks pass, Azure AD issues a token that allows Magic Suite to connect to your Exchange Online IMAP server
- The token is short-lived (typically 1 hour) and must be renewed regularly
- All access is logged in your Azure AD sign-in logs and Exchange audit logs
Security & Compliance
Access Control
Auditing
Search-MailboxAuditLog -Identity your-mailbox@yourcompany.com -StartDate (Get-Date).AddDays(-7) -ShowDetails
Revoking Access
Get-ApplicationAccessPolicy | Where-Object { $_.AppId -eq "eb6992c6-9e08-444d-be7d-17b490f2f3d3" }
# Remove specific policy
Remove-ApplicationAccessPolicy -Identity "policy-identity-from-above"
✅ Configuration Checklist
Before Going Live
Frequently Asked Questions
Q: Can Magic Suite access all our mailboxes?
Q: What data can Magic Suite access?
Q: How do we know if Magic Suite is accessing our mailbox?
Q: What happens if we revoke access?
Q: Can we use a regular user mailbox instead of a shared mailbox?
Q: How long does the client secret last?
Troubleshooting
Issue: "Access Denied" when testing the policy
- Verify admin consent was granted (check Enterprise Applications)
- Verify the policy exists:
Get-ApplicationAccessPolicy | Where-Object { $_.AppId -eq "eb6992c6-9e08-444d-be7d-17b490f2f3d3" } - Ensure the mailbox email address is spelled correctly in the policy
Issue: Cannot connect to Exchange Online PowerShell
- Install module:
Install-Module ExchangeOnlineManagement -Force - Ensure you have Exchange Administrator or Global Administrator role
- Try connecting with:
Connect-ExchangeOnline -UserPrincipalName your-admin@yourcompany.com
Issue: Magic Suite still cannot access mailbox after configuration
- Wait 5-10 minutes for changes to propagate across Microsoft's infrastructure
- Verify IMAP is enabled:
Get-CASMailbox your-mailbox@yourcompany.com | Select-Object ImapEnabled - Run the test again:
Test-ApplicationAccessPolicy -Identity your-mailbox@yourcompany.com -AppId eb6992c6-9e08-444d-be7d-17b490f2f3d3 - Contact Panoramic Data support if the issue persists