Skip to main content
Mitratech Success Center

Client Support Center

Need help? Click a product group below to select your application and get access to knowledge articles, webinars, training content, and release notes or to contact our support team.

Authorized users - log in to create a ticket, view tickets status and check your success plan details.

 

Oauth 2 for CMO Mailboxes

CMO mailboxes authentication mechanism has been upgraded from basic authentication to Oauth2. To access emails, the service accounts configured with CMO application currently needs basic authentication. From 2021, in order to connect, those accounts which are using the EWS protocol to connect to 365 require Modern Authentication, i.e. Oauth2.

Mailbox Configuration to Send Email

Following key controls is used to mails

<add key="Mail.Sending.ServerType" value="" />

Available options:

  • Smtp (it’s also a default value when value is not empty)
  • Microsoft365

SMTP has following Configuration:

Key

Type

Remark

Mandatory

Default value

Mail.Sending.Smtp.Server

String

SMTP server address, may include port (if port is not specified, then CMO selects port based on option specified for SSL).

Yes

clipboard_e9ca8887030175f67d056328d9db4c8d5.png

Mail.Sending.Smtp.NumberOfMessagesPerSession

String

Controls how many messages will be send within the same session. When this limit is exceeded, CMO resets existing connection and initiate new.

Yes

3

Mail.Sending.Smtp.UseAuth

Boolean

Controls if CMO connect to SMTP server anonymously or not.

Yes

False

Mail.Sending.Smtp.UseSsl

Boolean

Controls if SSL (TLS) is used or not.

 

False

Mail.Sending.Smtp.AuthType

String

Controls what authentication type / way is used. Possible values:

  • BasicAuth
  • GoogleOAuth2

Yes

BasicAuth

Basic Auth configuration:

Key

Type

Remark

Mandatory

Default value

Mail.Sending.Smtp.Login

String

Login used to connect to SMTP server

Yes

clipboard_e9ca8887030175f67d056328d9db4c8d5.png

Mail.Sending.Smtp.Password

String

Password used to connect to SMTP server

Yes

clipboard_e9ca8887030175f67d056328d9db4c8d5.png
Google OAuth2 Configuration:

Key

Type

Remark

Mandatory

Default value

Mail.Sending.Smtp.GoogleOAuth2.CertificatePath

String

Path to certificate for the service account. It should be path that can be used as is (without any additional resolving) to access the certificate (for account under website (IIS) is running)

Yes

clipboard_e9ca8887030175f67d056328d9db4c8d5.png

Mail.Sending.Smtp.GoogleOAuth2.ServiceAccount

String

Name of service account

Yes

clipboard_e9ca8887030175f67d056328d9db4c8d5.png
Mail.Sending.Smtp.GoogleOAuth2.GsuiteUser String Name of gsuite user to impersonate service account Yes clipboard_e9ca8887030175f67d056328d9db4c8d5.png

 

Microsoft 365 has following Configuration:

CMO supports two different authentication approaches for Microsoft 365. First one uses special service account user and requires admin consent (call it confidential application approach), second one allows to use regular (work / school) Microsoft  365 account and doesn’t require admin consent (call it public application approach).

Following setting controls what approach is used: Mail.Sending.Microsoft365.IntegrationType. It’s mandatory, has no default value. Possible values are Confidential and Public.

To use Public authentication flow a token must be configured. See ‘Configuring token for Microsoft 365 public application’ for the details.

Confidential Application Configuration:

Key

Type

Remark

Mandatory

Default value

Mail.Sending.Microsoft365.ConfidentialApp.ClientId

String

The client ID (a string representing a GUID)

Yes

clipboard_e5566416341940d968b9656c5e0af816b.png

Mail.Sending.Microsoft365.ConfidentialApp.TenantId

String

The tenant ID

Yes

clipboard_e137e791f37bb4926d6f96bc642813bbd.png

Mail.Sending.Microsoft365.ConfidentialApp.Secret

String

The application secret (client secret string)

Yes

clipboard_e38ecaa6f7167e99f4da1c6b1535b0f56.png

Mail.Sending.Microsoft365.ConfidentialApp.UserObjectId

String

Account Id (a string representing a GUID) of a user used to send / receive messages.

Yes

clipboard_ef999e7e4d16a12a796148f1b451a3fb1.png

Following Graph API scopes are required (Application permissions, Admin consent must be provided):

  • Mail.Read
  • Mail.ReadWrite
  • Mail.Send
Public Application Configuration 

Key

Type

Remark

Mandatory

Default value

Mail.Sending.Microsoft365.PublicApp.ClientId

String

The client ID (a string representing a GUID)

Yes

clipboard_e18371d56c96e38c7fa9b9d4e5d02b000.png

Mail.Sending.Microsoft365.PublicApp.TenantId

String

The tenant ID

Yes

clipboard_ec1ad681f2fd1d732262c24293c052106.png

Mail.Sending.Microsoft365.PublicApp.RedirectUri

String

The identity provider URL (named the instance) and the sign-in audience

Yes

clipboard_ed1ffecd931af8a727fb5af88b4774dd0.png

Mail.Sending.Microsoft365.PublicApp.AccountName

String

User name of the MS 365 user account that can be by Web App to communicate with Graph API to send / receive messages.

Yes

clipboard_ee39f6b211e52a09a791fb09404b26169.png

Following Graph API scopes are required (Delegated permissions):

  • Mail.Read
  • Mail.ReadWrite
  • Mail.Send
  • offline_access

To use Public authentication flow a token must be configured. See ‘Configuring token for Microsoft 365 public application’ for the details.

Mailbox Configuration to Receive Email 

The key Mail.Receiving.ServerType controls what way is used to receive messages. Possible values are:

  • IMAP
  • POP3
  • MAPI
  • Microsoft365

Note: Nothing has been changed for the MAPI (it works in the same way as before).

 

IMAP Configuration

Key

Type

Remark

Mandatory

Default value

Mail.Receiving.Imap.Server

String

IMAP server address, may include port (if port is not specified, then CMO selects port based on option specified for SSL).

Yes

clipboard_ec1759b4db3a415dcf67189b98f44f05a.png

Mail.Receiving.Imap.UseSSL

Boolean

Controls if SSL (TLS) is used or not.

Yes

False

Mail.Receiving.Imap.AuthType

String

Controls what authentication type / way is used. Possible values:

  • BasicAuth
  • GoogleOAuth2

Yes

BasicAuth

 

Basic Auth Configuration

Key

Type

Remark

Mandatory

Default value

Mail.Receiving.Imap.Login

String

Login used to connect to SMTP server

Yes

clipboard_e57ec205916625d1bc57b80ac922a73c4.png

Mail.Receiving.Imap.Password

String

Password used to connect to SMTP server

Yes

clipboard_ef62d67aff8b66465a5b5c61f2c9759e7.png

 

Google OAuth2 Configuration 

Key

Type

Remark

Mandatory

Default value

Mail.Receiving.Imap.GoogleOAuth2.CertificatePath

String

Path to certificate for the service account. It should be path that can be used as is (without any additional resolving) to access the certificate (for account under website (IIS) is running)

Yes

clipboard_e37542f24ec7c4090c674ea20a9240385.png

Mail.Receiving.Imap.GoogleOAuth2.ServiceAccount

String

Name of service account

Yes

clipboard_e354f6924bf115b8d1537d076a29d8752.png

Mail.Receiving.Imap.GoogleOAuth2.GsuiteUser

String

Name of gsuite user to impersonate service account

Yes

clipboard_eddd37a4dfa84fbd731f84a624519a4ee.png

POP3 Configuration 

Key

Type

Remark

Mandatory

Default value

Mail.Receiving.Pop3.Server

String

Pop server address, may include port (if port is not specified, then CMO selects port based on option specified for SSL).

Yes

clipboard_edf422e71843151eb2cb0463837e37420.png

Mail.Receiving.Pop3.UseSSL

Boolean

Controls if SSL (TLS) is used or not.

Yes

False

Mail.Receiving.Pop3.AuthType

String

Controls what authentication type / way is used. Possible values:

  • BasicAuth
  • GoogleOAuth2

Yes

BasicAuth

 

Basic Auth Configuration

Key

Type

Remark

Mandatory

Default value

Mail.Receiving.Pop3.Login

String

Login used to connect to SMTP server

Yes

clipboard_e8420cc26b58c9ccee0787301f493c3e4.png

Mail.Receiving.Pop3.Password

String

Password used to connect to SMTP server

Yes

clipboard_e6b2e9a5f5dd3e22390a0f30a15ae2281.png

GoogleOAuth2 Configuration 

Key

Type

Remark

Mandatory

Default value

Mail.Receiving.Pop3.GoogleOAuth2.CertificatePath

String

Path to certificate for the service account. It should be path that can be used as is (without any additional resolving) to access the certificate (for account under website (IIS) is running)

Yes

clipboard_ec410a8c3f282da6adcb99c25e1b6f75f.png

Mail.Receiving.Pop3.GoogleOAuth2.ServiceAccount

String

Name of service account

Yes

clipboard_e6ffc6d1964aa8fdc93483d0a37e9c6bf.png

Mail.Receiving.Pop3.GoogleOAuth2.GsuiteUser

String

Name of gsuite user to impersonate service account

Yes

clipboard_e89fb27a17881d351736d74c61b2315ba.png

Microsoft 365 Configuration 

Receiving message also supports two different approaches for authentication:  Public and Confidential (it is exactly the same as for sending). The key Mail.Receiving.Microsoft365.IntegrationType controls what approach is used. Possible values are Confidential, Public. It’s mandatory, has no default value.

Confidential Application Configuration

Key

Type

Remark

Mandatory

Default value

Mail.Receiving.Microsoft365.ConfidentialApp.ClientId

String

The client ID (a string representing a GUID)

Yes

clipboard_e2d8a14cffcc355088404d569858b6d8b.png

Mail.Receiving.Microsoft365.ConfidentialApp.TenantId

String

The tenant ID

Yes

clipboard_ea465de1913f75a0c3580388e1785ea94.png

Mail.Receiving.Microsoft365.ConfidentialApp.Secret

String

The application secret (client secret string)

Yes

clipboard_ecf87f8a6e917cfdf48116e9b037f2f39.png

Mail.Receiving.Microsoft365.ConfidentialApp.UserObjectId

String

Account Id (a string representing a GUID) of a user used to send / receive messages.

Yes

clipboard_e4194dbcf2da0ea44c348e209722ec07d.png

Following Graph API scopes are required (Application permissions, Admin consent must be provided): Mail.Read, Mail.ReadWrite, Mail.Send

Public Application Configuration

Key

Type

Remark

Mandatory

Default value

Mail.Receiving.Microsoft365.PublicApp.ClientId

String

The client ID (a string representing a GUID)

Yes

clipboard_e04c058d334042932c49a6788cf4f25b1.png

Mail.Receiving.Microsoft365.PublicApp.TenantId

String

The tenant ID

Yes

clipboard_e3254c9a0f6444551ad09136979dd09a0.png

Mail.Receiving.Microsoft365.PublicApp.RedirectUri

String

The identity provider URL (named the instance) and the sign-in audience

Yes

clipboard_e7bf6d1bce3abaa7be7c0050d10c2f01f.png

Mail.Receiving.Microsoft365.PublicApp.AccountName

String

User name of the MS 365 user account that can be by Web App to communicate with Graph API to send / receive messages.

Yes

clipboard_e5309c829d46d11ba93e4f072d8292adc.png

Following Graph API scopes are required (Delegated permissions): Mail.Read, Mail.ReadWrite, Mail.Send, offline_access.

To use Public authentication flow a token must be configured. See ‘Configuring token for Microsoft 365 public application’ for the details.

Document Import and New Action Mailboxes

CMO has ability to use different mailboxes for document import and new action. They allow to override some parameters (but not all). Other parameters are inherited from Mail.Receiving. Configuration keys for these mailboxes have exactly the same meaning, type, possible values, etc., therefore only names of those keys are provided:

  • Mail.NewAction.EmailClient.AuthType
  • Mail.NewAction.EmailClient.GoogleOAuth2.CertificatePath
  • Mail.NewAction.EmailClient.GoogleOAuth2.ServiceAccount
  • Mail.NewAction.EmailClient.GoogleOAuth2.GsuiteUser
  • Mail.NewAction.EmailClient.Server
  • Mail.NewAction.EmailClient.Login
  • Mail.NewAction.EmailClient.Password
  • Mail.NewAction.EmailClient.Microsoft365.IntegrationType
  • Mail.NewAction.EmailClient.Microsoft365.PublicApp.ClientId
  • Mail.NewAction.EmailClient.Microsoft365.PublicApp.TenantId
  • Mail.NewAction.EmailClient.Microsoft365.PublicApp.RedirectUri
  • Mail.NewAction.EmailClient.Microsoft365.PublicApp.AccountName
  • Mail.NewAction.EmailClient.Microsoft365.ConfidentialApp.ClientId
  • Mail.NewAction.EmailClient.Microsoft365.ConfidentialApp.TenantId
  • Mail.NewAction.EmailClient.Microsoft365.ConfidentialApp.Secret
  • Mail.NewAction.EmailClient.Microsoft365.ConfidentialApp.UserObjectId
  • Mail.DocumentImport.EmailClient.AuthType
  • Mail.DocumentImport.EmailClient.GoogleOAuth2.CertificatePath
  • Mail.DocumentImport.EmailClient.GoogleOAuth2.ServiceAccount
  • Mail.DocumentImport.EmailClient.GoogleOAuth2.GsuiteUser
  • Mail.DocumentImport.EmailClient.Server
  • Mail.DocumentImport.EmailClient.Login
  • Mail.DocumentImport.EmailClient.Password
  • Mail.DocumentImport.EmailClient.Microsoft365.IntegrationType
  • Mail.DocumentImport.EmailClient.Microsoft365.PublicApp.ClientId
  • Mail.DocumentImport.EmailClient.Microsoft365.PublicApp.TenantId
  • Mail.DocumentImport.EmailClient.Microsoft365.PublicApp.RedirectUri
  • Mail.DocumentImport.EmailClient.Microsoft365.PublicApp.AccountName
  • Mail.DocumentImport.EmailClient.Microsoft365.ConfidentialApp.ClientId
  • Mail.DocumentImport.EmailClient.Microsoft365.ConfidentialApp.TenantId
  • Mail.DocumentImport.EmailClient.Microsoft365.ConfidentialApp.Secret
  • Mail.DocumentImport.EmailClient.Microsoft365.ConfidentialApp.UserObjectId

Note: The same account can be used to send / receive emails when Microsoft 365 is used. 

Configuring Token for Microsoft 365 Public Application

To configure token (Public Application auth flow) CMO.Microsoft365TokenHelper tool should be used. The tool is available in package folder of website.

The tool has following configuration:

  1. <add key="ClientId" value=""/>
  2. <add key="TenantId" value=""/>
  3. <add key="RedirectUri" value=""/>
  4. <add key="CacheFileName" value=""/>
  5. <add key="CacheDirectory" value=""/>

ClientId, TenantId, RedirectUri are the same as for Web App configuration. CacheFileName (default value is cmo_msal_cache.dat) controls name of cache file which will be created and used to store serialized OAuth 2.0 tokens. CacheDirectory controls directory where that file will be created. To serialize token use following steps: 

  1. Specify parameters in the configuration file.
  2. Run the tool.
  3. Enter ‘Y' to add token or ‘N’ (anything except 'Y’) to quit.
  4. In the opened dialog box enter credentials for a valid MS 365 account.
  5. Review and accept all requested permissions.
  6. Repeat steps 3-5 for all required mailboxes.

Once cache file is generated go to Web app and put the file to directory (or generate the file to that directory using CacheDirectory configuration option) available for Web app instance. In the web config set following settings (based on the generated file name and its location):

  1. <add key="MSAL.Cache.Folder" value="" />
  2. <add key="MSAL.Cache.FileName" value="" />

Note: The tool uses Local Machine protection scope, hence the tool must be run on web server. In case when a few web application instances points to the same db need to repeat that procedure for every server or configure to use the scheduler for specific web server (web application instance).

To verify that CMO is able to authenticate request to Graph API (to send and receive messages) use the following dialog (available under SA account):

clipboard_eb6dc93a0247020975772060833c55080.png 

Azure Configuration

Following parameters should be configured and specified in the web.config (for corresponding keys) in order to use 'Confidential application auth flow (for example to send emails).

clipboard_e3eaedbf97804e50c9ad932bfa26342a6.png

clipboard_e1e5d40311eb46d228e3efcc5b3273d0b.png

clipboard_e21e96d55850342030b2ba48e356bacbb.png

Configuration to receive emails (or create Action / Document via email) is the same, just use corresponding prefix instead of Mail.Sending, e.g. Mail.Receiving.Microsoft365.ConfidentialApp.ClientId instead of Mail.Sending.Microsoft365.ConfidentialApp.ClientId.

Following parameters should be configured and specified in the web.config (for corresponding keys) in order to use 'Public application auth flow (for example to send emails).

clipboard_e2c0eb2609b418b50e3a269e52268e84c.png

clipboard_efac01c98f4ab80ed2d359c2dfda1bf67.png

clipboard_e256e24e9b2de7bc07761d7d28b1d8eb3.png

Configuration to receive emails (or create Action / Document via email) is the same, just use corresponding prefix instead of Mail.Sending, e.g. Mail.Receiving.Microsoft365.PublicApp.ClientId instead of Mail.Sending.Microsoft365.PublicApp.ClientId.

Google Mail Configuration

Mail.Google.Com (https://mail.google.com/) scope is required (that allows to read, compose, send, and permanently delete all your email from Gmail). It can be configured here:

clipboard_e498f3747908c5f28714194519daa3d84.png

Service account can be configured here:

clipboard_e920a288762ebd7464a5845c4c5328d87.png

clipboard_e4641e2969fb425f3952644e5b484a90d.png

Project can be created using this screen:

clipboard_ef7cc3f5020fb8bed2a0f4ffb9038969f.png

  • Was this article helpful?