Send and Receive Emails in Odoo with an Email Server

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

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

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

本文档的范围

This document is mainly dedicated to Odoo on-premise users who don’t benefit from an out-of-the-box solution to send and receive emails in Odoo, unlike Odoo Online & Odoo.sh.

警告

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

You will find here some useful information on how to integrate your own email solution with 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 .

Please refer to Microsoft’s documentation to configure a SMTP relay for your Odoo’s IP address.

‎如何使用 G Suite 服务器‎

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

限制条件

Please note that port 25 is blocked for security reasons on our SaaS and Odoo.sh platform. Try using 465, 587, or 2525.

Use a default “From” email address

有时,电子邮件的”From”(传出)地址可能属于不同的域,这可能是一个问题。

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, the Odoo’s redistributed email would get rejected by some recipients’ mail servers.

为了避免此类问题,您应该确保所有电子邮件都使用授权域名中的”来自”地址。

如果您的 MTA 支持 `SRS(发送者重写计划)<https://en.wikipedia.org/wiki/Sender_Rewriting_Scheme>`_,您可以启用它来处理这些情况。但是,这更为复杂,需要更多的技术知识,而这些知识并非本文档所涵盖的。

相反,您也可以配置 Odoo 来自己做类似的事情:

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

    ../../../_images/alias-domain.png
  2. Click on Outgoing Mail Servers

  3. Create a new one.

  4. Fill its From Filter.

    ../../../_images/outgoing_server_from_filter.png
    • Use a domain (such as mycompany.example.com) to keep the original “From” address for mails that come from that domain.

    • Use an address (such as outgoing@mycompany.example.com) to allow only that outgoing address.

    • Keep it empty to use this server for any email address.

    With this configuration in place, if Odoo sends an email that doesn’t match any of the from filters, it will alter the email’s “From” before sending it to the MTA.

    It will use the default outgoing email address, composed like this: {mail.default.from}@{mail.catchall.domain}.

  5. 在开发人员模式下,转到:菜单选择:’设置 – – >技术 – – >参数 – – >系统参数’。

  6. Add these system parameters:

    • mail.default.from: local part of default outgoing email address.

    • mail.catchall.domain: domain part of default outgoing email address.

如何管理入站邮件

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中所有别名都是可自定义的。

对象别名可以从各自的配置视图进行编辑。要编辑捕获和反弹别名,您首先需要激活:参考:’开发者模式<developer-mode>`.

然后前往 :menuselection:`设置 –> 技术 –> 参数 –> 系统参数`定义别名( mail.catchall.alias 和 * mail.bounce.alias* )。

../../../_images/system-parameters.png

注解

默认情况下,每 5 分钟在 Odoo 本地获取一次入站消息。您可以在:<developer-mode>`.参考:”开发人员模式”中更改此值。转到 :菜单选择:’设置 - >技术 - >自动化 - >预定操作”,并查找 Mail: Fetchmail Service

为事务和群发邮件设置不同的专用服务器

Odoo is subject to a daily email limit to prevent abuse. 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.

注解

默认的传出电子邮件服务器已经配置。除非出于技术原因想要使用特定的外部传出电子邮件服务器,否则您不应创建替代电子邮件服务器。

为此,您应该首先激活:开发人员模式<developer-mode>。然后转到:菜单选择:’设置 ->技术 - >外向”电子邮件服务器。在那里,您必须创建两个电子邮件 MTA 服务器设置。一个用于交易电子邮件,一个用于群发邮件服务器。请务必将事务性电子邮件服务器的优先级标记为低至大规模电子邮件服务器。

现在,转到:菜单选择:’电子邮件营销 ->设置’,并启用*Dedicated Server*。通过这些设置,Odoo 将服务器用于交易电子邮件的低优先级,而此处选定的服务器用于群发邮件。请注意,在这种情况下,您必须设置域名的发送者策略框架 (SPF) 记录,以包括交易和群发邮件服务器。如果您的服务器与 xxxx.odoo.com 一起存在,可用的选项是森丁蓝和邮件,因为您的电子邮件将来自 xxxx.odoo.com 域。