# mail.enable()

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/domain/mail/enable/
Language: zh

`domain.mail.enable({ subdomain?, replace? }) → Promise<Mail>`

将所有邮件需求都以一个电话发送: 路由、 发送政策、 签名密钥和对齐政策。 在顶点, 或者当顶点已经从别处收到时, 或放在子域上 。

Status: four records, one call · refuses to replace live mail · the key is reused

```javascript
await domain.mail.enable();                         // addresses at @example.com
await domain.mail.enable({ subdomain: "team" });    // at @team.example.com, apex untouched
await domain.mail.enable({ replace: true });        // replace live mail servers — deliberate
```

## 无法在未询问的情况下替换邮件 {#live-mx}

> **mail_would_replace_mx,并附加了当前服务器**
>
> 工作配置一发生作用,客户就会在工作配置上停止接收, 并在第一道丢失信息时发现。 details.current - 展示出来,提供两个出路

```javascript
import { IaGenifyError } from "iagenify";

try {
  await domain.mail.enable();
} catch (err) {
  if (err instanceof IaGenifyError && err.code === "mail_would_replace_mx") {
    console.log("mail currently goes to:", err.details.current);
    await domain.mail.enable({ subdomain: "team" });   // or { replace: true }
  }
}
```

大部分人已经将这两个域附加到某个地方, 已经收到邮件。 这是正常的, 不是边缘的 。

## 返回值 {#returns}

```javascript
{
  host: "team.example.com", subdomain: "team",
  mx: [{ name, content, priority }],
  spf: "…", dkim: { selector, publicKey }, dmarc: "…",
  posed: [...], replaced: [...], failed: [...],
  dns: { mxOk, spfOk, dkimOk, dmarcOk },
  ready: true,
}
```

`failed` 是一个读:一个记录,没有登陆,就是邮件,不会有效,再次打电话只代表缺失的东西。

## 主机, 不是一个域名 {#host}

顶部和每个子域分别配置,每个外部都有自己的记录、钥匙和政策——顶部的政策不包括子领域。

## 两次调用它 没有什么意义 {#idempotent}

它写下缺少的东西。 配置的主机第二次调用不会改变任何变化, 这使得它能够安全运行于接口 。

## 所构成的,以及为什么 {#content}

- 严格的发送者政策——软政策——让欺骗得以通过。
- 发送者名单点在我们名字上 所以中继器可以改变 而不触及客户区
- 2048比特的签名键,没有测试旗
- 观察政策首先:在任何人阅读报告之前,严格规定不得打破邮寄名单。

- [mail.status()](/zh/sdk/ref/domain/mail/status): 阅读证人。
- [mail.dmarc()](/zh/sdk/ref/domain/mail/dmarc): 之后再加把劲
- [api.mail](/zh/sdk/ref/mail): 在上面创建邮箱

```python
domain.mail.enable()                      # addresses at @example.com
domain.mail.enable(subdomain="team")      # at @team.example.com, apex untouched
domain.mail.enable(replace=True)          # replace live mail servers — deliberate
```

```python
from iagenify import IaGenifyError

try:
    domain.mail.enable()
except IaGenifyError as error:
    if error.code != "mail_would_replace_mx":
        raise
    print("mail currently goes to:", error.details["current"])
    domain.mail.enable(subdomain="team")   # or replace=True
```

```python
{
    "host": "team.example.com", "subdomain": "team",
    "mx": [{"name": ..., "content": ..., "priority": ...}],
    "spf": "…", "dkim": {"selector": ..., "publicKey": ...}, "dmarc": "…",
    "posed": [...], "replaced": [...], "failed": [...],
    "dns": {"mxOk": ..., "spfOk": ..., "dkimOk": ..., "dmarcOk": ...},
    "ready": True,
}
```
