> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.generaltranslation.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure a Custom Email Provider with Terraform

> Learn how to configure a custom email provider using Terraform Auth0 Provider

You can configure a [custom email provider](https://auth0.com/docs/customize/email/configure-a-custom-email-provider) with the Terraform Auth0 provider. The Terraform Auth0 provider is used to interact with the [Auth0 Management API](https://auth0.com/docs/api/management/v2) in order to configure an Auth0 Tenant. To learn more, review Terraform’s [Auth0 Provider](https://registry.terraform.io/providers/auth0/auth0/latest/docs) documentation.

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  * If you are using Terraform to configure a custom email provider, delete your existing Auth0 tenant custom [email](https://auth0.com/docs/customize/email/configure-a-custom-email-provider) provider.
  * Auth0 has a maximum limit of one Action for Actions associated with the following triggers: custom-phone-provider and custom-email-provider.
</Callout>

The following steps outline how to a custom email provider using Terraform:

1. Create an [`auth0_action`](https://registry.terraform.io/providers/auth0/auth0/latest/docs/resources/phone_provider):

```terraform lines theme={null}
resource "auth0_action" "custom_email_provider" {
  name    = "Custom Email Provider"
  runtime = "node20"
  deploy  = true
  code    = <<-EOT
    /**
    * Handler to be executed while sending an email notification
    * @param {Event} event - Details about the user and the context in which they are logging in.
    * @param {CustomEmailProviderAPI} api - Methods and utilities to help change the behavior of sending a email notification.
    */
    exports.onExecuteCustomEmailProvider = async (event, api) => {
      // Code goes here
      return;
    };
  EOT
  supported_triggers {
    id      = "custom-email-provider"
    version = "v1"
  }
}
```

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  In order to bind a Terraform `auth0_action` to an `auth0_trigger_action`, set the auth0\_action to `deploy = true`. To learn more, read Terraform's [auth0\_action](https://registry.terraform.io/providers/auth0/auth0/latest/docs/resources/action) documentation.
</Callout>

2. Bind the `auth0_action` to the custom-email-provider `auth0_trigger_action`:

```terraform lines theme={null}
resource "auth0_trigger_action" "custom_email_provider" {
  trigger = "custom-email-provider"
  actions {
    id           = auth0_action.custom_email_provider.id
    display_name = auth0_action.custom_email_provider.name
  }
   depends_on = [
    auth0_action.custom_email_provider
  ]
```

3. Configure the `auth0_email_provider` resource to use the `auth0_action`:

```terraform lines theme={null}
resource "auth0_email_provider" "custom_email_provider" {
  name                 = "custom"
  enabled              = true
  default_from_address = "accounts@example.com"
  credentials {}
  depends_on = [
    auth0_trigger_actions.custom_email_provider
  ]
```

To learn more, read Terraform’s [auth0\_email\_provider](https://registry.terraform.io/providers/auth0/auth0/latest/docs/resources/email_provider) documentation.

<div id="troubleshoot">
  ## Troubleshoot
</div>

**Scenario: Custom email provider configured using Terraform is not taking effect, and the <Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-JP/ja-jp/glossary?term=auth0-dashboard" tip="Auth0 Dashboard: サービスを構成するためのAuth0の主製品。" cta="用語集の表示">Auth0 Dashboard</Tooltip> displays a different Action.**

You may have multiple custom provider Actions with `deploy: true`. Auth0 has a maximum limit of one Action for Actions associated with the following triggers: `custom-phone-provider` and `custom-email-provider`.

* If you encounter this scenario, it’s recommended that you [list your Actions](https://auth0.com/docs/api/management/v2/actions/get-actions) to identify any duplicates to delete.
* If you encounter this scenario after managing your custom providers through multiple methods (Terraform, Auth0 Dashboard, <Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-JP/ja-jp/glossary?term=management-api" tip="Management API: 顧客が管理タスクを実行できるようにするための製品。" cta="用語集の表示">Management API</Tooltip>, and/or Auth0 SDKs) it is advisable to reset the custom provider configuration. We recommend you refrain from using multiple methods to manage your custom provider.

To reset the custom email provider, navigate to [Auth0 Dashboard > Branding](https://manage.auth0.com/#/branding) and select **Email Provider** . Then, select the **Reset** button to restore your custom provider to its default
