# How to Setup Email with OAuth

## Introduction

Leapwork is capable of sending e-mails in various ways. For example, when configuring a schedule, it is possible to add an e-mail action to forward the results of the schedule to mail recipients. Another way to send an e-mail is to use the [Send e-mail building block](/content/product/documentation/building-blocks/data-driven/send-e-mail/index.html) as part of a flow.

Leapwork supports two different ways to connect to an email server:

- Simple Mail Transfer Protocol (SMTP) Server (refer to this [article](https://support.leapwork.com/s/article/E-mail-Settings-via-SMTP))  
- Open Authentication (OAuth)

**Note:** _SMTP is the default approach for sending an e-mail. Email settings access is only available to Admin._

## Set Up Email with OAuth:

OAuth is an open-standard authorization protocol or framework that provides applications the ability to secure designated access.

To send an e-mail, Leapwork needs access to an OAuth configuration (Leapwork uses an OAuth 2.0 which is a secure open-standard authorization protocol. Which protects your data by providing access to the data without revealing the identity or credentials), which is configured in the E-mail settings part of Leapwork’s settings. You need to contact your mail and network administrators to ensure that Leapwork can access the OAuth configuration and that you have the required permission to send e-mails.

To register the daemon application follow: [https://learn.microsoft.com/en-us/azure/healthcare-apis/register-application](https://learn.microsoft.com/en-us/azure/healthcare-apis/register-application)

Go to [https://portal.azure.com/](https://portal.azure.com/) to register your daemon application. If your application is already registered then under Overview, you can find all the required details like Client ID, Tenant ID, and Client Secret.

To get the 'Client Secret' you need to select the "Certificates & secrets" section which is available on the left panel:

After selecting the "Certificates and secrets" tab you will able to see the details:

Applications are authorized to call APIs when they are granted permission by Admin as part of the consent process, select the "API Permissions" tab from the left:

After collecting the Client ID, Tenant ID, and Client secret, now move to Leapwork.

Open the 'Email Settings' in Leapwork: Settings >> Email Settings

Select the **Protocol** = "OAuth" from the drop-down:

Enter **From Mailbox** details in the given field.

Enter **Instance** details in the given field.

Enter **API URL** details in the given field.

Enter **Tenant** details in the given field.

Enter **Client ID** details in the given field.

Enter **Client Secret** details in the given field.

**Note**: **Instance** and **API URL** are the default fields. The values of these are auto-filled and you can change these values based on your requirement.

**Note**: The **Test connection** button is disabled in OAuth.

Click **Send test email** button to use the configuration to send a test e-mail to the e-mail address specified in the **From Mailbox** field.

The success message appears to let you know that the email is sent successfully.

Click **Cancel** button to cancel the details.

Click **Save** button to save the details.

If you have any questions, please reach out to our [Priority Support](mailto:prioritysupport@leapwork.com) team.
