# Mailgun

![Mailgun.svg](https://assets.relyanceuat.xyz/images/docs/6006946150157/6006746689293.svg)
Mailgun is a transactional email automation service built for developers and information technology professionals. It is used to send outgoing emails through SMTP and can also receive and track emails using its powerful API. Organizations use Mailgun in marketing campaigns as well as for typical server email churn.

In order to integrate Mailgun with Relyance AI you will need an **Account API Key**.

#### In Mailgun:

![Mailgun-1.png](https://assets.relyanceuat.xyz/images/docs/6006946150157/6006937741581.png)
1. Login to your Mailgun account.
2. Navigate to the Mailgun menu and select **Settings**.
3. Select **API Keys** from the menu.
4. Copy the **Private API key**.

#### In the Relyance AI application:

1. Login to your Relyance account.
2. Navigate to the **Settings** Menu in the bottom left-hand side.
3. Select **Integrations**.
4. Click on the **Vendor Integration** tab.
5. Find the **Mailgun** integration card and click it to open its connections.
6. Under **Authentication Method**, choose **Custom**.
8. Paste the **Account API Key** into its respective field.

![Mailgun-2.png](https://assets.relyanceuat.xyz/images/docs/6006946150157/6007192570765.png)

9. Click **Authenticate**.
10. At this point, you should see the following result on the Vendor Integrations page:

![Mailgun-3.png](https://assets.relyanceuat.xyz/images/docs/6006946150157/6007162431501.png)

11. Congratulations, you are now connected to **Mailgun**.

<!-- failure-modes:begin (generated from the integration catalog; do not hand-edit) -->

## If the connection reports Connected but returns nothing

These are the ways this integration comes back empty without reporting an error. Generated from the integration catalog, so it tracks what the connection actually asks for.

1. **A feature you enabled returns nothing.** Some scopes belong to a feature rather than to the connection: **Data subject requests** needs `Primary Account API key`. Turning the feature on after the connection exists does not widen the grant it already holds, so re-authenticate the connection.
2. **A credential rotated at the vendor is not picked up here.** **Account API Key** is stored when you save the connection, so regenerating the value at the vendor breaks the next scan until it is re-pasted here. Recording the expiry on the connection means Relyance warns you before it lapses.

<!-- failure-modes:end -->

<!-- terraform-examples:begin (generated from the integration catalog; do not hand-edit) -->

## Manage this integration with Terraform

Connections for this integration can be managed as code with the [Relyance Terraform provider](https://registry.terraform.io/providers/Relyance/relyance/latest). Non-secret fields go in `auth.params`; secret fields go in `auth.secrets_wo`, which is write-only — never stored in Terraform state. Rotate secrets by bumping `auth.secrets_wo_version`.

```hcl
resource "relyance_integration_connection" "mailgun" {
  vendor = "mailgun"
  name   = "<your connection name>"

  auth = {
    method = "api-key"
    params = {
      data_storage_location = "us"
    }
    # Secret fields are write-only: sent to Relyance, never stored in state.
    secrets_wo = {
      API_KEY = var.mailgun_api_key
    }
    secrets_wo_version = 1
  }

  scans = { "data-inspection" = { enabled = true } }
}
```

<!-- terraform-examples:end -->
