From 696a5ecfdd7b4b0793af005f256442b1ebd95a05 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Fri, 27 Mar 2020 13:05:54 +0000 Subject: [PATCH] [FIX] mail: cannot route catchall bounced email Configure a catchall address in Odoo, send an email to that very address, it should bounce back to the user asking him not to send any email to the catchall but the email is never sent. Internally, Odoo reply to the user using the `To` header of the original email as `From` of the bounced email. It should never use the catchall address as it is not a valid email to send email from. closes odoo/odoo#53036 Task: 2277661 X-original-commit: 86c8f0960f709692aa787ae62d446b4427a7c312 Signed-off-by: Thibault Delavallee (tde) --- addons/mail/models/mail_thread.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index be476cda0f4..ee16931f25e 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -691,8 +691,10 @@ class MailThread(models.AbstractModel): bounce_from = self.env['ir.mail_server']._get_default_bounce_address() if bounce_from: bounce_mail_values['email_from'] = tools.formataddr(('MAILER-DAEMON', bounce_from)) - else: + elif self.env['ir.config_parameter'].sudo().get_param("mail.catchall.alias") not in message['To']: bounce_mail_values['email_from'] = tools.decode_message_header(message, 'To') + else: + bounce_mail_values['email_from'] = tools.formataddr(('MAILER-DAEMON', self.env.user.email_normalized)) bounce_mail_values.update(mail_values) self.env['mail.mail'].sudo().create(bounce_mail_values).send()