Adding an OAuth-Based Email Server through Rest API

  1. Import the following curl command with your details:
    curl --location --request PUT 'https://<OTM host>/api/20210901/system/mail/server' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic Zm9vLmJhckBvcmFjbGUuY29tOkNIQU5HRU1F' \
    --data-raw '{
        "host": "hostname.us.com",
        "port": 123,
        "sender": {
            "displayName": "aName",
            "emailAddress": "aName@example.com"
        },
        "auth": {
            "authType": "OAUTH2_AUTH",
            "oAuth2Details": {
                "username": "theUserName",
                "oAuth2Provider": "MS_OAUTH2",
                "secret": "OAuth2_client_secret",
                "clientId": "oauthClientId",
                "tenant": "ATenatntId"
            }
        },
        "connectionSecurity": {
            "connectionSecurityType": "NO_CONNECTION_SECURITY"
        }
    }'
    	
    Response: 
        {
        "host": "hostname.us.com",
        "port": 123,
        "sender": {
            "displayName": "aName",
            "emailAddress": "aName@example.com"
        },
        "auth": {
            "authType": "OAUTH2_AUTH",
            "oAuth2Details": {
                "oAuth2Provider": "MS_OAUTH2",
                "username": "theUserName",
                "clientId": "oauthClientId",
                "tenant": "ATenatntId"
            }
        },
        "connectionSecurity": {
            "connectionSecurityType": "NO_CONNECTION_SECURITY"
        }
    }
    
  2. After running the PUT request, the email server gets added in the xmlpserver > Administration > Email screen. An email server named "DV SMTP Server" gets added.