# 集成邮件系统

在 Alertmanager 使用邮箱通知，只需要定义好 SMTP 相关的配置，并且在 receiver 中定义接收方的邮件地址即可。

```yaml
global:
  [ smtp_from: <tmpl_string> ]
  [ smtp_smarthost: <string> ]
  [ smtp_hello: <string> | default = "localhost" ]
  [ smtp_auth_username: <string> ]
  [ smtp_auth_password: <secret> ]
  [ smtp_auth_identity: <string> ]
  [ smtp_auth_secret: <secret> ]
  [ smtp_require_tls: <bool> | default = true ]
```

完成全局 SMTP 之后，还需要为 receiver 配置 email\_configs，定义一组接收告警的邮箱地址，如下所示：

```yaml
name: <string>
email_configs:
  [ - <email_config>, ... ]
```

每个 email\_config 中定义相应的接收人邮箱地址、邮件通知模板等信息，如果当前接收人需要单独的 SMTP 配置，那直接在 email\_config 中进行覆盖。

```yaml
[ send_resolved: <boolean> | default = false ]
to: <tmpl_string>
[ html: <tmpl_string> | default = '{{ template "email.default.html" . }}' ]
[ headers: { <string>: <tmpl_string>, ... } ]
```

* 如果当前收件人需要接受告警恢复（global 中的 <mark style="color:blue;">**`resolve_timeout`**</mark>）的通知的话，在 email\_config 中定&#x4E49;**`send_resolved`**&#x4E3A; true。
* 如果所有的邮件配置使用了相同的 SMTP 配置，则可以直接定义全局的 SMTP 配置。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bohans.gitbook.io/devops/prometheus/prometheus-gao-jing-chu-li/alertmanager/pei-zhi/shi-yong-receiver-jie-shou-gao-jing-xin-xi/ji-cheng-you-jian-xi-tong.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
