‎如何使用我的邮件服务器在 Odoo 中发送和接收电子邮件‎

‎本文档主要面向 Odoo 本地用户,这些用户无法从开箱即用的解决方案中发送和接收 Odoo 中的电子邮件中受益,这与”Odoo Online <https://www.odoo.com/trial>`__ & Odoo.sh.”不同。‎

‎如果您的公司中没有人用于管理电子邮件服务器,我们强烈建议您选择 Odoo 托管解决方案。他们的电子邮件系统可以立即工作,并由专业人士监控。不过,如果您希望自己管理电子邮件服务器的声誉,您仍可以使用自己的电子邮件服务器。‎

‎您将在这里找到一些有用的信息,了解如何将您自己的电子邮件解决方案与 Odoo 集成。‎

注解

Office 365邮件服务器无法方便地从Odoo这样的主机发送外部邮件。请参阅`微软文档 <https://support.office.com/en-us/article/How-to-set-up-a-multifunction-device-or-application-to-send-email-using-Office-365-69f58e99-c550-4274-ad18-c805d654b4c4>`__,了解如何设置。

如何管理出站邮件

作为系统管理员,请转到菜单选择 设置 ‣ 常规设置,然后选中 外部电子邮件服务器 。然后,单击 传出邮件服务器 以创建一个服务器并引用电子邮件服务器的 SMTP 数据。填写所有信息后,单击 测试连接

‎下面是 G Suite 服务器的典型配置。‎

../../../_images/outgoing_server.png

‎然后在常规设置中设置您的电邮域名。‎

‎我可以使用 Office 365 服务器吗?‎

You can use an Office 365 server if you run Odoo on-premise. Office 365 SMTP relays are not compatible with Odoo Online unless you configure Odoo to force the outgoing “From” address (see below).

请参阅 微软文档 <https://support.office.com/en-us/article/How-to-set-up-a-multifunction-device-or-application-to-send-email-using-Office-365-69f58e99-c550-4274-ad18-c805d654b4c4>,为您的 Odoo 的 IP 地址配置 SMTP 中继。

‎如何使用 G Suite 服务器‎

您可以将 G Suite 服务器用于任何 Odoo 托管类型。为此,您需要设置 SMTP 中继服务。配置步骤在 Google 文档中介绍.

‎符合 SPF 标准‎

‎如果您使用 SPF(发件人策略框架)来增加传出电子邮件的可传递性,请不要忘记在域名设置中授权 Odoo 作为发送主机。以下是 Odoo 在线的配置:‎

  • ‎如果没有为 SPF 设置 TXT 记录,请创建一个具有以下定义的记录:v_spf1 include:_spf.odoo.com _~all

  • 如果已经为SPF设置TXT记录,在通过Odoo Online发送邮件的域名中添加“include:_spf.odoo.com”,通过G Suite发送的则可为:v=spf1 include:_spf.odoo.com include:_spf.google.com ~all

找到 `此<https://www.mail-tester.com/spf/>,在你自己的域寄存器中以准确步骤创建或修改TXT记录。

新SPF记录最多可能需要48个小时才能生效,但这通常会更快地发生。

注解

为一个域添加多个SPF记录可能导致邮件被分类为垃圾。我们建议仅修改一个SPF记录以授权给Odoo。

允许DKIM

如果你的邮件服务器启用了DKIM(域密钥标识邮件),你也需要进行同样的操作。对于Odoo Online 和 Odoo.sh,你需要向“odoo._domainkey.odoo.com”添加DNS“odoo._domainkey”CNAME记录。例如,对于“foo.com”,它们应有一条“odoo._domainkey.foo.com”记录,这是值为“odoo._domainkey.odoo.com”的CNAME。

Choose allowed “From” email addresses

Sometimes, an email’s “From” (outgoing) address can belong to a different domain, and that can be a problem.

For example, if a customer with address mary@customer.example.com responds to a message, Odoo will try to redistribute that same email to other subscribers in the thread. But if the domain customer.example.com forbids that kind of usage for security (kudos for that), the Odoo’s redistributed email would get rejected by some recipients’ mail servers.

To avoid those kind of problems, you should make sure all emails use a “From” address from your authorized domain.

If your MTA supports SRS (Sender Rewriting Scheme), you can enable it to handle these situations. However, that is more complex and requires more technical knowledge that is not meant to be covered by this documentation.

Instead, you can also configure Odoo to do something similar by itself:

  1. 在一般设置中设置你的域名。

    ../../../_images/alias_domain.png
  2. In developer mode, go to Settings ‣ Technical ‣ Parameters ‣ System Parameters.

  3. Add one system parameter from these:

    • If you want all your outgoing messages to use the same “From” address, use the key mail.force.smtp.from and set that address as value (such as outgoing@mycompany.example.com).

    • If you want to keep the original “From” address for emails that use your same domain, but change it for emails that use a different domain, use the key mail.dynamic.smtp.from and set as value the email address that should be used in those cases (such as outgoing@mycompany.example.com).

如何管理入站邮件

Odoo依赖通用的电子邮件别名来收取入站邮件。

根据你的邮件服务器,可能有几种方法来收取邮件。最简单也最推荐的方法是在邮件服务器中按Odoo别名管理邮件地址。

  • 在你的邮件服务器中创建相应的电子邮件地址(catchall@、bounce@、sales@ 等)。

  • 在一般设置中设置你的域名。

    ../../../_images/alias_domain.png
  • 如果你使用本地部署的Odoo,请在Odoo中为每个别名创建一个 入站邮件服务器 。你也可以在一般设置中进行操作。根据你的电子邮件提供商的设置填写表单。将 对入站邮件执行的操作 留空。在填写完毕所有信息后,点击 测试和确认

../../../_images/incoming_server.png
  • 如果你使用Odoo Online或Odoo.sh,我们建议将入站邮件重定向到Odoo的域名,而不是仅使用你自己的邮件服务器。这样,你将不会延迟接收入站邮件。实际上,Odoo Online每小时仅收取一次外部服务器的入站邮件。你应在电子邮件服务器中将所有电子邮件地址的重定向设置为Odoo的域名(例如, catchall@mydomain.ext 设为 catchall@mycompany.odoo.com )。

小技巧

All the aliases are customizable in Odoo. Object aliases can be edited from their respective configuration view. To edit catchall and bounce aliases, you first need to activate the developer mode from the Settings Dashboard.

../../../_images/developer_mode.png

Then refresh your screen and go to Settings ‣ Technical ‣ Parameters ‣ System Parameters to customize the aliases (mail.catchall.alias & * mail.bounce.alias*).

../../../_images/system_parameters.png

注解

By default inbound messages are fetched every 5 minutes in Odoo on-premise. You can change this value in developer mode. Go to Settings ‣ Technical ‣ Automation ‣ Scheduled Actions and look for Mail: Fetchmail Service.