[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) <tde@openerp.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user