Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] mail_from_force: force the "From" address to a fixed email #308

Closed
dreispt opened this issue Oct 12, 2018 · 11 comments
Closed

[RFC] mail_from_force: force the "From" address to a fixed email #308

dreispt opened this issue Oct 12, 2018 · 11 comments

Comments

@dreispt
Copy link
Sponsor Member

dreispt commented Oct 12, 2018

In some scenarios, the outgoing mail server enforces the "From" email address to be the one for User connected to the mail server.

This means that if I connect to the outgoing mail server using "admin", all sent emails must be from "admin@example.com", and an email From "daniel.reis@example.com" would be rejected by the mail server.

AFAICS this behavior is not configurable, so I'm preparing an extension to solve this:
The From would be changed to keep the sender's name, but use the Outgoing Mail user's address.

Following the example above, Daniel's email From would be something like "Daniel Reis admin@example.com" or "On behalf of Daniel Reis admin@example.com"

Technically, we just need to override the _get_default_from method of mail.message.

@pedrobaeza
Copy link
Member

The problem here is that your mail server supports any address or enforce the main one. This is called "mail relay". We use Mailgun as mail provider with authorized domains.

In a nutshell, it's not something of Odoo, but on the rest of the infrastructure.

@dreispt
Copy link
Sponsor Member Author

dreispt commented Oct 12, 2018

In this scenario, the mail server is configured according to a corporate policy, and I cant change any of them. So I need Odoo to "behave" accordingly.

Additionally, from a security PoV I see the point for this policy of not "impersonating" someone else, and there are more companies out there using it.
For example, GitHub notifications "From" adress carry your name, but a fixed notifications email address.

@pedrobaeza
Copy link
Member

Yeah, but you can put whatever you want on your From, that mail server will change it. There's a middle solution that some mails servers do that is "X in the name of Y", but again is not in Odoo part, but on the mail server that allows that.

@dreispt
Copy link
Sponsor Member Author

dreispt commented Oct 12, 2018

Yeah, but you can put whatever you want on your From, that mail server will change it.

It doesn't. It rejects the email message.

There's a middle solution that some mails servers do that is "X in the name of Y",

I researched that. My particular case is using MS Exchange.
We can have Daniel send an email of a Group ("Odoo"), but we can't have a "Odoo" send an email on behalf of "Daniel" (my need).

but again is not in Odoo part, but on the mail server that allows that.

Again, is this case I can't and I don't want to.

@pedrobaeza
Copy link
Member

Ok, if you think this can be solved that way, try and tell me. I remember to struggle with the same problem and MS exchange being a pain, finally using other smtp server.

@dreispt
Copy link
Sponsor Member Author

dreispt commented Oct 30, 2018

Update:

My current fix is not strong enough: the SMTP server enforces that the Header "Sender" corresponds to the "From" in the message envelope. For mails to go through I need to ensure that both the Sender and the messages's From corresponds to the user connected to the SMTP server.

The most relevant commit is: odoo/odoo@a4597fe and the relevant discussion on the Odoo framework is odoo/odoo#3347. It seems that there are some PRs trying to fix this in the core.

@pedrobaeza
Copy link
Member

This is what I was trying to explain you 😉

@dreispt
Copy link
Sponsor Member Author

dreispt commented Oct 30, 2018

Olivier Dony wrote:

Users should also be aware of the limitations of their outgoing SMTP providers. To use Odoo in multi-user environments you need a true SMTP relay that accepts arbitrary From values, exactly as if you were running a mailing-list software (which you actually are). Typically GMail will not work well, as it is a personal SMTP, not a corporate one.

@dreispt
Copy link
Sponsor Member Author

dreispt commented Oct 30, 2018

Using my own SMTP server is not something I want to do.
So my only alternative is to really force the Sender and From addresses to the mail server's user.

@eLBati
Copy link
Member

eLBati commented Jul 2, 2019

For v10 and v12 another implementation was made: mail_outbound_static

Additional info at odoo/odoo#20911

I think we should go on with mail_outbound_static

@dreispt
Copy link
Sponsor Member Author

dreispt commented Jul 8, 2019

I missed that one, thanks for pointing it out.
I guess that makes my proposed module redundant.

@dreispt dreispt closed this as completed Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants