配置 DNS 记录以便在 Odoo 中发送电子邮件¶
本文档介绍了用于证明电子邮件发件人合法性的三种互补认证协议(SPF、DKIM 和 DMARC)。不遵守这些协议将大大降低电子邮件到达目的地的机会。
使用 默认 Odoo 子域地址**(例如,`@company-name.odoo.com`)的 **Odoo 在线版 和 Odoo.sh 数据库已预先配置为 发送符合 SPF、DKIM 和 DMARC 协议的验证电子邮件。
如果选择使用 自定义域,则必须 正确配置 SPF 和 DKIM 记录,以防止电子邮件被当作垃圾邮件隔离或无法投递给收件人。
如果使用 默认 Odoo 电子邮件服务器从自定义域发送电子邮件,则必须如下所示配置 SPF 和 DKIM 记录。如果使用外发电子邮件服务器,则必须使用该电子邮件服务和自定义域专用的 SPF 和 DKIM 记录。
注解
电子邮件服务提供商对收到的电子邮件采用不同的规则。即使邮件通过了 SPF 和 DKIM 检查,也可能被归类为垃圾邮件。
SPF(发送方策略框架)¶
发件人策略框架(SPF)协议允许域名所有者指定哪些服务器可以从该域名发送电子邮件。当服务器接收到传入的电子邮件时,它会根据发件人的 SPF (发件人策略框架) 记录,检查发送服务器的 IP 地址是否在允许的 IP 列表中。
在 Odoo 中,**SPF 测试在数据库的 常规设置 下的 别名域 字段中定义的反弹地址**上执行。如果使用自定义域作为 别名域,则必须将其配置为符合 SPF 标准。
域名的 SPF 策略是通过 TXT 记录设置的。创建或修改此记录的方法取决于托管域名的 DNS(域名系统) 区域的提供商。
如果域名还没有 SPF 记录,请使用以下输入创建一个:
v=spf1 include:_spf.odoo.com ~all
如果域名**已经有 SPF 记录,则必须更新该记录**。请勿创建新记录,因为一个域名只能有一条 SPF 记录。
Example
如果 TXT 记录为`v=spf1 include:_spf.google.com ~all`,则编辑它以添加`include:_spf.odoo.com`: v=spf1 include:_spf.odoo.com include:_spf.google.com ~all
使用 MXToolbox SPF Record Check 等工具检查 SPF 记录。创建或修改 SPF 记录的过程取决于托管域名 DNS 区域的提供商。下面列出了 最常见的提供商 及其说明文档。
DKIM(域名密钥识别邮件标准)¶
域名密钥识别邮件(DKIM)允许用户使用数字签名对电子邮件进行身份验证。
When sending an email, the Odoo email server includes a unique DKIM signature in the headers. The recipient’s server decrypts this signature using the DKIM record in the database’s domain name. If the signature and the key contained in the record match, it proves the message is authentic and has not been altered during transport.
使用 Odoo 电子邮件服务器 从自定义域 发送电子邮件时,必须 启用 DKIM。
Add a CNAME record for domain¶
To enable DKIM, add a canonical name (CNAME) record to the domain name system (DNS) zone of the domain name:
odoo._domainkey IN CNAME odoo._domainkey.odoo.com.
If the domain name is company-name.com, make sure to create a CNAME record where the CNAME record
(key/name) is odoo._domainkey.company-name.com, and the canonical name (value/content) is
odoo._domainkey.odoo.com.. For example, note the differences between each key/value in italics:
Key |
odoo._domainkey |
||
|---|---|---|---|
Value |
odoo._domainkey.odoo.com. |
||
OR |
odoo._domainkey.dbname.odoo.com. |
… where dbname is the name of the Odoo database. |
On most DNS platforms, the DNS provider adds the custom domain (e.g., company-name.com) by default. In this case, the key looks different while the value remains the same:
Key |
odoo._domainkey.company-name.com |
… where company-name.com is the custom domain. |
|
|---|---|---|---|
Value |
odoo._domainkey.odoo.com. |
||
OR |
odoo._domainkey.dbname.odoo.com. |
… where dbname is the name of the Odoo database. |
注解
If the DNS provider does not add the custom domain by default, make sure to include it.
Add a CNAME record for subdomain¶
If there’s a subdomain (e.g., marketing in marketing.company-name.com), add a CNAME record to include it for compliance as well:
Key |
odoo._domainkey.marketing |
… where marketing is the subdomain. |
|
|---|---|---|---|
OR |
odoo._domainkey.marketing.company-name.com |
… where company-name.com is the custom domain. |
|
Value |
odoo._domainkey.odoo.com. |
||
OR |
odoo._domainkey.dbname.odoo.com. |
… where dbname is the name of the Odoo database. |
See DNS provider documentation¶
创建或修改 CNAME 记录的方法取决于托管域名 DNS 区域的提供商。下面列出了 最常见的提供商 及其说明文档。
Check if the DKIM record is valid using a tool like MXToolbox DKIM Record Lookup. Enter example.com:odoo in the DKIM lookup tool, specifying
that the selector being tested is odoo for the custom domain example.com.
DMARC(基于域的消息验证、报告和一致性)¶
DMARC(基于域的消息验证、报告和一致性)记录是一个统一了 SPF(发件人政策框架) 和 DKIM (域名密钥识别邮件) 的协议。域名 DMARC 记录中包含的指令告诉目标服务器如何处理未通过 SPF 和/或 DKIM 检查的传入电子邮件。
注解
本文档的目的是帮助 理解 DMARC 对电子邮件可送达性的影响,而不是提供创建 DMARC 记录的精确说明。请参考 DMARC.org 等资源来设置 DMARC 记录。
有三种 DMARC 策略:
p=nonep=quarantinep=reject
p=quarantine 和 p=reject 指示接收电子邮件的服务器隔离该电子邮件,或者在 SPF 或 DKIM 检查失败时忽略它。
注解
要通过 DMARC,DKIM 或 SPF 检查必须通过,域必须一致。如果托管类型是 Odoo 云端版,则需要在发送域上配置 DKIM 才能通过 DMARC。
通过 DMARC 通常意味着电子邮件将被成功发送。但需要注意的是,其他因素(如垃圾邮件过滤器)仍可能拒绝或隔离邮件。
p=none 用于域所有者接收有关使用其域的实体的报告。它不应影响送达率。
Example
_dmarc IN TXT “v=DMARC1; p=none; rua=mailto:postmaster@example.com” 表示将向 postmaster@example.com 发送汇总 DMARC 报告。
常见提供商的 SPF、DKIM 和 DMARC 文档¶
要全面测试配置,请使用 `Mail-Tester <https://www.mail-tester.com/>`_工具,该工具可在一封电子邮件中提供内容和配置的完整概览。Mail-Tester 还可用于为其他不太知名的提供商配置记录。