> ## Documentation Index
> Fetch the complete documentation index at: https://mage-staging.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Alerting status updates in Email

> Get status updates sent to your email inbox.

<img alt="Email" src="https://yourreclaimedlife.com/wp-content/uploads/2018/12/email-marketing-without-permission.jpg" />

## Create notification\_config

In the root of your project’s folder (e.g. `default_repo/`), open the file
`metadata.yaml`.

> Project folder name
>
> If you initialized Mage using a different project name, then your root folder
> will be named differently. `default_repo` is the default project name if you
> didn’t customize it.

In the `default_repo/metadata.yaml` file, add a section with the following
configuration or update the existing `notification_config` section:

```yaml theme={null}
notification_config:
  alert_on:
    - trigger_failure
    - trigger_passed_sla
```

If you omit the `alert_on` section it will default to `trigger_failure` and `trigger_passed_sla`.

Options:

* `trigger_failure`: alert when a run of a trigger fails
* `trigger_success`: alert when a run of a trigger succeeds
* `trigger_passed_sla`: alert when a run of a trigger passes sla

## Configure email settings

In the `default_repo/metadata.yaml` file, add a section with the following
configuration or update the existing `notification_config` section:

```yaml theme={null}
notification_config:
  alert_on:
    ...
  email_config:
    smtp_host: ...
    smtp_mail_from: ...
    smtp_user: ...
    smtp_password: ...
    to_emails:
      - someone_lucky@mage.ai
      - eng@mage.ai
```

Change the values for each key under the `email_config` section.

## Customize message templates

You can customize message templates in `notification_config`. Here is an example config:

```yaml theme={null}
notification_config:
  alert_on:
    ...
  email_config:
    ...
  message_templates:
    failure:
      title: Failed to execute pipeline {pipeline_uuid} at {execution_time}
      details: >
        Failed to execute pipeline {pipeline_run_url}.
        Pipeline uuid: {pipeline_uuid}. Trigger name: {pipeline_schedule_name}.
        Test custom message."
    success:
      title: ...
      details: ...
    passed_sla:
      title: ...
      details: ...
```

You can customize the message template for `success`, `failure`, `passed_sla` scenarios. For each message template,
you can specify `title` and either `summary` or `details`.

* `title` is used in email subject
* If you specify the `summary`, the email body will be your `summary` + the url of the pipeline run page
* If you specify the `details`, the `details` will be used as your email body

To interpolate variables in the messaget template, you can use `{variable_name}` syntax.
Hare are the supported variables: `error`, `execution_time`, `pipeline_run_url`, `pipeline_schedule_id`,
`pipeline_schedule_name`, `pipeline_uuid`.

For `pipeline_run_url`, the default host is `http://localhost:6789`. You can specify `MAGE_PUBLIC_HOST` to be
the host url you want to use in the notification messages.

***

## What next?

Whenever a pipeline run is successfully completed or fails, an email will be
delivered to all the inboxes listed under `to_emails`.

Here is an example of what an email could look like:

|                                                                                                                                                                                                                                                                                                        |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Successfully ran Pipeline `example_pipeline` with Trigger 79 `hourly_trigger` at execution time `2022-09-28 19:00:00`.<br />Open [http://localhost:6789/pipelines/example\_pipeline/triggers/79](http://localhost:6789/pipelines/example_pipeline/triggers/79) to check pipeline run results and logs. |
