Friday, August 13, 2021
1 change · master
Enhancements to existing features
Odoo now supports certificate-based email server authentication and reduces sender spoofing when sending messages. This helps improve email deliverability, lowers the chance of messages being marked as spam, and gives administrators safer options for configuring mail relays such as Office 365.
Original PR description
Purpose ======= The global purpose of this PR is to improve the score of the emails sent by Odoo as well as allowing to authenticate the Odoo server with SSL certificate. SSL authentication…
Purpose
=======
The global purpose of this PR is to improve the score of the emails sent by
Odoo as well as allowing to authenticate the Odoo server with SSL certificate.
SSL authentication
==================
We want to be able to authenticate our servers with a certificate for the
entire domain name instead of using an username and a password. That way
we will be able to configure an SMTP relay (on Office 365 e.g.) based on an
SSL certificate instead of an hard-coded IP address.
The host name of the server is defined in the MX DNS record on your domain.
The certificate must be valid for your domain name.
e.g.
> Host: openerp-org.mail.protection.outlook.com
Port: 25
Username: \<keep it blank>
Password: \<keep it blank>
Security: STARTTLS
Email: admin@odoobe.com
No spoofing
===========
Before, we were spoofing the FROM headers all the times. E.g., if someone has
an email address outside of the current email server (e.g. `test@gmail.com`)
we sent it using the default mail server and we spoofed the FROM. This causes
some issues, because emails may be marked as spam by the email clients. A
small fix for stable was merged at odoo/odoo#69218 and will be reverted as this merge
improves that behavior.
Now, we try to *not* spoof the mail from in the SMTP protocol. For that purpose
we define a default email address which is used when no mail server is
available for the sender email address. In that case, the email address
of the sender will be "encapsulated" in the default email address
(e.g. `"Admin (admin@gmail.com)" <notifications@odoo.com>`).
To know for which email address an outgoing mail server can be used, we use a
field "`from_filter`" which can be either an complete email address or a
domain name.
The headers are changed following this heuristic
1. We first look for a mail server which match the entire mail FROM
in that case, we do not change the email header (not needed)
2. If not found, we search a mail server which match the domain name of
the mail from (do not need to change the headers in that case)
3. If not found, find the mail server linked to the "notifications"
email (defined in the system parameter). Then change the FROM header
to the notifications email, and put the old one in the name part of
this header.
e.g.
Initial mail from: "Admin" < admin@example.com >
Final mail from: "Admin (admin@odoo.com)" < notifications@odoo.com >
4. If no notifications email is configured or if no mail server are
found for the notifications email, fallback to the old system and
spoof the FROM header. In that case we do not have the choice if we
want to send the email, he will probably be marked as spam.
LINKS
Task-2367946