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

如果你是Odoo Online或Odoo.sh的用户…

你什么也不需要做!Odoo为你的服务器设置了自己的邮件服务器。 接收和发送电子邮件功能开箱即用!

除非你计划发送大量邮件,可能需要使用外部邮件服务器,否则只需享受你的新Odoo数据库即可。

本文档的范围

本文件 主要针对Odoo本地部署的用户 ,他们无法像`Odoo Online <https://www.odoo.com/trial>`__和`Odoo.sh <https://www.odoo.sh>`__那样,直接通过开箱即用的解决方案在Odoo上收发邮件。

警告

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

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

注解

Office 365 email servers don’t easily allow to send external emails from hosts like Odoo. Refer to Microsoft’s documentation to make it work.

如何管理出站邮件

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

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

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

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

注解

如你在Gmail电邮地址 测试连接 时收到``[AUTHENTICATIONFAILED] Invalid credentials (Failure)`` 警告,启用 安全性较低的应用程序访问 选项。你可`在此访问 <https://myaccount.google.com/lesssecureapps?pli=1>`_直接链接。

此外,请启用Gmail账户的IMAP设置。

‎我可以使用 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。

限制条件

请注意,出于安全原因,端口25被阻塞。 尝试使用587、465或2525。

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 )。

小技巧

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.

然后前往 :menuselection:`设置 –> 技术 –> 参数 –> 系统参数`定义别名( 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.

Set up different dedicated servers for transactional and mass mails

Odoo’s e-mail server has the capability of sending 200 e-mails per day on Odoo SH Cloud Platform. However, if needed, you can use a separate Mail Transfer Agent (MTA) servers for transactional e-mails and mass mailings. Example: use Odoo’s own mail server for transactional e-mails, and Sendgrid, Amazon SES, or Mailgun for mass mailings. Another alternative is to use Postmark for transactional e-mails, and Amazon SES or Sendgrid for mass mailings.

注解

A default outgoing email server is already configured. You should not create an alternative one unless you want to use a specific external outgoing email server for technical reasons.

To do this, you should first activate the developer mode and then go to Settings ‣ Technical ‣ Outgoing e-mail servers. There you have to create two e-mail MTA server settings. One for transactional e-mails and one for mass mail servers. Be sure to mark the priority of transactional e-mail servers as low as the mass email servers.

Now, go to Email Marketing ‣ Settings and enable Dedicated Server. With these settings, Odoo uses the server with the lower priority for transactional emails, and the server here selected for mass mails. Note that in this case, you have to set your domain’s Sender Policy Framework (SPF) records to include both transactional and mass mail servers. If your server resides with xxxx.odoo.com, the available options are Sendinblue and Mailchimp, as your e-mails would be originated from the xxxx.odoo.com domain.