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

# Connect your app to Mailgun

> Connect your app to Mailgun to send transactional email, manage sending domains, and track delivery events from your Lovable app.

export const connector_0 = "Mailgun"

[Mailgun](https://www.mailgun.com/) is a transactional email service that lets your Lovable app send email programmatically over the Mailgun API. It's designed for apps that need reliable delivery for receipts, notifications, password resets, alerts, and reports, with detailed tracking for bounces, complaints, and unsubscribes.

With Mailgun, your app can:

* Send transactional email through the Mailgun API
* Send from a verified sending domain you manage in Mailgun
* Track delivery events such as bounces, complaints, and unsubscribes
* Read message and event metadata for auditing or in-app status
* Read domain and route information from your Mailgun account

Mailgun is a good fit when you want to send from your own domain, keep control of your sender reputation, or already manage your sending in Mailgun.

<Tip>
  For standard transactional emails (signup confirmations, password resets, receipts, internal notifications), use the built-in [Lovable Emails](/features/custom-emails).

  Reach for the Mailgun connector when you want to send from your own verified domain, scale beyond Lovable Emails, or you already manage your sending in Mailgun.
</Tip>

## Common use cases and example apps

| Example app                             | Example prompt                                                                                           | Description                                                                                                                                                            |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Order confirmations and receipts**    | *Use Mailgun to send order confirmation and receipt emails after checkout.*                              | **Send transactional notifications from app events.**<br />The app triggers Mailgun email sends whenever a user completes a purchase or status changes.                |
| **Account lifecycle email**             | *Use Mailgun to send password reset and email-verification messages from `noreply@mydomain.com`.*        | **Power account-lifecycle email from your own domain.**<br />The app generates secure links and sends them through Mailgun using your verified sending domain.         |
| **Form-to-email apps**                  | *Use Mailgun and build a contact form that emails submissions to our support inbox.*                     | **Turn form submissions into routed emails.**<br />The app validates the submission, formats the content, and sends it to the right recipient via Mailgun.             |
| **Scheduled reports and digests**       | *Use Mailgun to email a weekly KPI digest every Monday at 9am.*                                          | **Deliver recurring reports by email.**<br />The app compiles the data, renders an email, and sends it on a schedule.                                                  |
| **Alerts and monitoring**               | *Use Mailgun to email me whenever an order over \$1,000 is placed.*                                      | **Surface high-signal events through email alerts.**<br />The app watches for matching events and emails the right people so they can act quickly.                     |
| **Bounce and deliverability dashboard** | *Use Mailgun and build a dashboard showing bounces, complaints, and unsubscribes from the last 30 days.* | **Use Mailgun event data to monitor deliverability.**<br />The app reads Mailgun events and presents them in-app so you can clean lists and protect sender reputation. |
| **Domain status admin page**            | *Use Mailgun and build an admin page that lists our sending domains and their verification status.*      | **Surface Mailgun account state inside your app.**<br />The app reads domain information from Mailgun so operators can manage sending without leaving the product.     |

## How to connect Mailgun

Workspace **admins** and **owners** can connect Mailgun.

You can create multiple Mailgun connections using different API keys, which is useful for separating environments (for example, development and production), targeting different Mailgun accounts, or using keys with different rate limits.

When the connection is created, Mailgun becomes available across all projects in the workspace.

### Prerequisites

Before connecting Mailgun, make sure you have:

* A Mailgun account
* A verified sending domain in that Mailgun account
* A Mailgun Private API key
* The region where your Mailgun account is hosted (EU or US)
* Lovable workspace owner or admin role

<Note>
  All email sent through this connector counts toward your Mailgun plan and is billed by Mailgun, not Lovable.
</Note>

### Step 1: Get a Mailgun Private API key

A Private API key lets your Lovable app authenticate with the Mailgun API. You can create separate keys for different environments or apps.

To create a Mailgun Private API key:

<Steps>
  <Step title="Open your Mailgun account">
    Sign in to the [Mailgun app](https://app.mailgun.com/) with the account that owns your sending domain.
  </Step>

  <Step title="Open API keys">
    Go to **Account → Security → API keys**.
  </Step>

  <Step title="Create or copy a Private API key">
    Create a new Private API key (give it a descriptive name, for example `Lovable integration`) or copy an existing one.
  </Step>

  <Step title="Note your account region">
    Note whether your Mailgun account is hosted in the **EU** or **US** region. You'll need to select the matching region in Lovable.
  </Step>
</Steps>

<Warning>
  Your Private API key functions like a password. Keep it secure and never share it publicly. You'll need it in the next step.
</Warning>

See Mailgun documentation for detailed instructions: [Mailgun API reference](https://documentation.mailgun.com/docs/mailgun/api-reference/intro/).

### Step 2: Connect Mailgun to Lovable

You can create multiple connections using different API keys.

<Steps>
  <Step title="Open Mailgun in Connectors">
    Go to **Connectors → App connectors** and select **Mailgun**.
  </Step>

  <Step title="Add a connection">
    Click **Add connection**.
  </Step>

  <Step title="Configure the connection">
    1. **Display name**: name the connection, for example `Mailgun Prod`.
    2. **API region**: select the region your Mailgun account is hosted in (**European Union** or **United States**). The default is **European Union**. The region must match the account the API key belongs to. A US key will not authenticate against the EU API.
    3. **Private API key**: paste your Mailgun Private API key.
    4. **Who can access this connection**: keep access limited to specific people or invite the entire workspace. See [**Who can manage connections**](/integrations/introduction#who-can-manage-connections) for more information.
  </Step>

  <Step title="Connect">
    Click **Connect**.
  </Step>
</Steps>

When connected, your Lovable apps can start sending email and reading account data through Mailgun.

## Sending from your domain

Mailgun sends email from domains you've verified in your Mailgun account. The connector does not configure DNS or verify domains for you.

Before sending, make sure your sending domain is set up in the Mailgun app and shows as verified, with the required DKIM and SPF records added at your DNS provider.

When prompting Lovable, mention the domain you want to send from (for example, `noreply@mydomain.com`) so the generated app uses it consistently.

## Limitations

The Mailgun connector cannot:

* Verify or register sending domains for you (configure these in the Mailgun app first)
* Receive Mailgun event webhooks directly through the connector (you can poll Mailgun's events API instead, or configure webhooks to a Mailgun-side endpoint outside Lovable)
* Refresh or rotate API keys automatically. To rotate, generate a new key in Mailgun and update the Lovable connection
* Support per-end-user Mailgun authentication (each connection uses a single shared API key, scoped to the workspace)
* Use more than one region per connection (a single connection authenticates against either the EU or US Mailgun API)

## How to unlink projects from a {connector_0} connection

Editors and above can remove specific projects from a connection without deleting the connection entirely. The connection will remain available for other projects.

To unlink projects:

<Steps>
  <Step title="Open Connectors">
    Open **Connectors**, then go to **App connectors**, and select **{connector_0}**.
  </Step>

  <Step title="Open the connection">
    Open the connection you want to manage.
  </Step>

  <Step title="Select projects">
    Under **Linked projects**, check the projects you want to unlink.
  </Step>

  <Step title="Confirm">
    Click **Unlink projects** and confirm.
  </Step>
</Steps>

When unlinked, those projects will no longer have access to {connector_0} through this connection. If a project needs {connector_0} again, you can link it to any available connection.

## How to delete a {connector_0} connection

Workspace admins and owners can delete {connector_0} connections. Other members can delete a connection if they created it, or if they have been explicitly granted access to it.

<Warning>
  Deleting a connection is permanent and cannot be undone. It will remove the credentials from all linked projects, and any apps using this connection will stop working until a new connection is added.
</Warning>

Before deleting, review the **Linked projects** section to see which projects are currently using the connection.

To delete a connection:

<Steps>
  <Step title="Open Connectors">
    Open **Connectors**, then go to **App connectors**, and select **{connector_0}**.
  </Step>

  <Step title="Open the connection">
    Open the connection you want to remove.
  </Step>

  <Step title="Review linked projects">
    Review the **Linked projects** section.
  </Step>

  <Step title="Delete">
    Under **Delete this connection**, click **Delete** and confirm.
  </Step>
</Steps>
