Skip to content

Conversation

@cth-odoo
Copy link

Odoo 15.0 introduced the ability to use a specific email server depending on the "From". So a new section "Set up different outgoing servers in a multi-company environment" has been added in the documentation. This explains the logic applied to select the right email server.

@robodoo
Copy link
Collaborator

robodoo commented Dec 22, 2021

Copy link
Contributor

@tiku-odoo tiku-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cth-odoo Can you check over the edits and make the changes in the RST? I changed some of the wording and grammar, other than that it looks great! Thanks for submitting this improvement. :)

.. _Office 365 documentation:
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

Set up different outgoing servers in a multi-company environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cth-odoo Thanks for submitting these improvements. I have reviewed them and I have some requested changes.

Can we change this title to:

Setting up different outgoing email servers for a multi-company environment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @tiku-odoo Thanks for the review, looks fine !

Copy link
Contributor

@tiku-odoo tiku-odoo Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cth-odoo Thanks!

Can you explain what happens if no servers are returned after the query? For example, two servers are set with from filter email address, how will the transactional email be sent out?

Our current documentation states that Odoo will use two system parameters to set the "from" address of this email.

  • mail.default.from: local part of default outgoing email address.
  • mail.catchall.domain: domain part of default outgoing 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}.
`
https://www.odoo.com/documentation/saas-15.1/applications/general/email_communication/email_servers.html#use-a-default-from-email-address

Thanks for clarifying.

Tim

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @tiku-odoo

Here is what is done in the code : https://github.com/odoo/odoo/blob/1b9dd118cb0f305ed38b6326fa814336cbf16252/odoo/addons/base/models/ir_mail_server.py#L598

Basically, if there are no email server corresponding to the "From filter", the first email server found is used even if it was configured for another domain.

If there is no email server, the email will never be sent, just like in SaaS when you duplicate a database : the standard email server from Odoo is archived with the aim to avoid sending fake invoices to real customers during the testing process.

Hope this helps.

Set up different outgoing servers in a multi-company environment
================================================================

The "From Filter" allows to use a specific outgoing depending of the "From". If an email is sent from Odoo, the email server will be chosen as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "From Filter" allows for the use of a specific outgoing email server depending on the "From" email address that Odoo is sending on behalf of. When an email is sent from Odoo and the "From Filter" is configured, then the email server will be chosen as follows:


The "From Filter" allows to use a specific outgoing depending of the "From". If an email is sent from Odoo, the email server will be chosen as follows:

#. Odoo searches for an email server having the same "From Filter" as the "From" defined in the outgoing email. For example, if the "From" is foo@bar.com, only the email servers having the "From Filter" equals to foo@bar.com will be returned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odoo searches for an email server having the same "From Filter" as the "From" email address defined in the outgoing email. For example, if the "From" email address is test@example.com, only the email servers having the "From Filter" equal to test@example.com will be returned.


#. Odoo searches for an email server having the same "From Filter" as the "From" defined in the outgoing email. For example, if the "From" is foo@bar.com, only the email servers having the "From Filter" equals to foo@bar.com will be returned.

#. If not found, Odoo searches for an email server having the same domain in the "From Filter" as in the "From". For example, if the "From" is foo@bar.com, only the email servers having the "From Filter" equals to bar.com will be returned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no email servers are found, then Odoo searches for an email server having the same domain in the "From Filter" as in the "From" email address of the outgoing email. For example, if the "From" email address is test@example.com, only the email servers having the "From Filter" equal to example.com will be returned.


#. If not found, Odoo searches for an email server having the same domain in the "From Filter" as in the "From". For example, if the "From" is foo@bar.com, only the email servers having the "From Filter" equals to bar.com will be returned.

#. If not found, Odoo will return all email servers without any "From Filter".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no email servers are found after checking for the domain, then Odoo will return all email servers without any "From Filter" set.


#. If not found, Odoo will return all email servers without any "From Filter".

.. note:: If several email servers are found, Odoo will use the first one per priority.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: If several email servers are found, then Odoo will use the first one according to its priority. For example, if there are two email servers, one with a priority of 10 and the other with a priority of 20, then the email server with a priority of 10 will be used.

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.
xxxx.odoo.com domain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this paragraph can you change xxxx.odoo.com domain to:

mycompany.odoo.com domain

We made this change so that the "xxxx" not be taken out of context.

@tiku-odoo
Copy link
Contributor

@cth-odoo -- Can you take a look at the above edits when you have a moment? Thanks :)


#. If not found, Odoo searches for an email server having the same domain in the "From Filter" as in the "From". For example, if the "From" is foo@bar.com, only the email servers having the "From Filter" equals to bar.com will be returned.

#. If not found, Odoo will return all email servers without any "From Filter".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's 2 step after this

If no mail server are found for the email address, we search for a mail server for the "mail.default.from" (with the same priority "full match" > "domain match")

Copy link
Contributor

@tiku-odoo tiku-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more questions for you @std-odoo Thank you! :)


#. If not found, Odoo searches for an email server having the same domain in the "From Filter" as in the "From". For example, if the "From" is foo@bar.com, only the email servers having the "From Filter" equals to bar.com will be returned.

#. If not found, Odoo will return all email servers without any "From Filter".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@std-odoo Can you review the following edit, did I understand it correctly? The attached edit replaces this sentence:
If no email servers are found after checking for the domain, then Odoo will return all email servers without any "From Filter" set. Can you clarify?

What happens if there aren't any results from this query? Does anything need to be added about the notification encapsulation? Should we add this as a note to the other two pull requests on the from filter? Thanks :)

Should this previous query return no results, then Odoo performs a search for an email server using the system parameter: 'mail.default.from'. First, the email address listed will attempt to match an email server and then the domain will attempt a match.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have some steps missing I think, to resume the entire flow

  1. Find a mail server whose from_filter match the entire sender email address
  2. If not found, find a mail server whose from_filter match the sender email domain name
  3. If not found, find a mail server with from_filter=False (match everything)
  4. If not found find a mail server whose from_filter match notifications@odoo.com
  5. If not found, find a mail server whose from_filter match the domain name of the "notifications email"
  6. If not found return the first outgoing mail server (sorted by priority), in that case the mail configuration is bad and the email might me marked as spam

If no email servers are found after checking for the domain, then Odoo will return all email servers without any "From Filter" set.

So this is correct for step 3

Should this previous query return no results, then Odoo performs a search for an email server using the system parameter: 'mail.default.from'. First, the email address listed will attempt to match an email server and then the domain will attempt a match

This is correct for step 4 and 5

Hope it clarify

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@std-odoo Thanks for breaking the from_filter down. I performed some testing and for step 6 when no server is returned the email is said to be sent in Odoo but isn't received (probably due to spam). This is expected behavior, correct?

Also, just to confirm the "from filter" should be set in system parameters always (by default) and also should be set in the outgoing email server (if using)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can check in the server log to be sure the email was sent, but if you have at least one server and if it didn't match the email / notification email, yes it might be marked as spam.

Copy link
Contributor

@tiku-odoo tiku-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cth-odoo When you have a moment can you make the suggested edits to the RST? Thank you in advance :)

@robodoo
Copy link
Collaborator

robodoo commented Jun 15, 2022

Sorry, I didn't know about this PR and had to retrieve its information, you may have to re-approve it.

@robodoo
Copy link
Collaborator

robodoo commented Jun 15, 2022

@tiku-odoo tiku-odoo requested review from a team June 16, 2022 19:32
@tiku-odoo
Copy link
Contributor

@cth-odoo -- It doesn't appear that the requested edits were made to the RST file. Can you confirm you made the changes?

Thanks,
Tim

@AntoineVDV AntoineVDV changed the base branch from 15.0 to master June 20, 2022 09:53
@AntoineVDV AntoineVDV changed the base branch from master to 15.0 June 20, 2022 09:53
@C3POdoo C3POdoo requested a review from a team June 20, 2022 09:54
Copy link
Collaborator

@AntoineVDV AntoineVDV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, this branch needs to be rebased for the CI checks to be green ;)


The "From Filter" allows to use a specific outgoing depending of the "From". If an email is sent from Odoo, the email server will be chosen as follows:

#. Odoo searches for an email server having the same "From Filter" as the "From" defined in the outgoing email. For example, if the "From" is foo@bar.com, only the email servers having the "From Filter" equals to foo@bar.com will be returned.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap the lines before the 100th character. It makes the RST easier to work with and especially to review ;)


If no email server is found then Odoo will return the first outgoing email server (sorted by priority). In this case, it is likely the email configuration will be spoofing the email and it will be flagged as Spam.

.. note:: If several email servers are found, Odoo will use the first one per priority.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the content of note/warning/etc. directives below the directive:

.. note::
   If several email servers...

Otherwise it is interpreted as the title of the directive and is harder to maintain.

Copy link
Contributor

@tiku-odoo tiku-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cth-odoo -- I've made suggested changes, can you approve and change? I've limited the lines to 100 characters. Thanks for your help on this!

Tim :)

@samueljlieber samueljlieber merged commit 1168ba6 into 15.0 Aug 23, 2022
@samueljlieber samueljlieber deleted the cth-odoo-filter-from branch August 23, 2022 20:26
@samueljlieber
Copy link
Contributor

New PR: #2626

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants