diff --git a/addons/mail/models/mail_alias.py b/addons/mail/models/mail_alias.py
index bebc4719357..9ab9722d9cb 100644
--- a/addons/mail/models/mail_alias.py
+++ b/addons/mail/models/mail_alias.py
@@ -228,7 +228,7 @@ class Alias(models.Model):
def _get_alias_bounced_body_fallback(self, message_dict):
return _("""Hi,
The following email sent to %s cannot be accepted because this is a private email address.
-Only allowed people can contact us at this address.""", message_dict.get('to'))
+Only allowed people can contact us at this address.""", self.display_name)
def _get_alias_bounced_body(self, message_dict):
"""Get the body of the email return in case of bounced email.
diff --git a/addons/test_mail/tests/test_mail_gateway.py b/addons/test_mail/tests/test_mail_gateway.py
index 35597ee1299..8da6b228b9f 100644
--- a/addons/test_mail/tests/test_mail_gateway.py
+++ b/addons/test_mail/tests/test_mail_gateway.py
@@ -397,6 +397,33 @@ class TestMailgateway(TestMailCommon):
# Check if default (hardcoded) value is in the mail content
self.assertSentEmail('"MAILER-DAEMON" ', ['whatever-2a840@postmaster.twitter.com'], body_content='The following email sent to')
+ @mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
+ def test_message_process_alias_config_bounced_to(self):
+ """ Check bounce message contains the bouncing alias, not a generic "to" """
+ self.alias.write({'alias_contact': 'partners'})
+ bounce_message_with_alias = "The following email sent to %s cannot be accepted because this is a private email address." % self.alias.display_name.lower()
+
+ # Bounce is To
+ with self.mock_mail_gateway():
+ self.format_and_process(
+ MAIL_TEMPLATE, self.email_from, 'groups@example.com',
+ cc='other@gmail.com', subject='Should Bounce')
+ self.assertIn(bounce_message_with_alias, self._mails[0].get('body'))
+
+ # Bounce is CC
+ with self.mock_mail_gateway():
+ self.format_and_process(
+ MAIL_TEMPLATE, self.email_from, 'other@gmail.com',
+ cc='groups@example.com', subject='Should Bounce')
+ self.assertIn(bounce_message_with_alias, self._mails[0].get('body'))
+
+ # Bounce is part of To
+ with self.mock_mail_gateway():
+ self.format_and_process(
+ MAIL_TEMPLATE, self.email_from, 'other@gmail.com, groups@example.com',
+ subject='Should Bounce')
+ self.assertIn(bounce_message_with_alias, self._mails[0].get('body'))
+
@mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models')
def test_message_process_alias_defaults(self):
""" Test alias defaults and inner values """