diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index b1772eb047e..5b90a655c61 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -352,7 +352,7 @@ class Channel(models.Model): # real mailing list: multiple recipients (hidden by X-Forge-To) if self.alias_domain and self.alias_name: return { - 'email_to': ','.join(formataddr((partner.name, partner.email)) for partner in whitelist), + 'email_to': ','.join(formataddr((partner.name, partner.email)) for partner in whitelist if partner.email), 'recipient_ids': [], } return super(Channel, self)._notify_email_recipients(message, whitelist.ids) diff --git a/addons/test_mail/tests/test_mail_channel.py b/addons/test_mail/tests/test_mail_channel.py index 74e49ce7de4..79ab747fed5 100644 --- a/addons/test_mail/tests/test_mail_channel.py +++ b/addons/test_mail/tests/test_mail_channel.py @@ -155,7 +155,15 @@ class TestChannelFeatures(common.BaseFunctionalTest, common.MockEmails): """ Posting a message on a mailing list should send one email to all recipients """ self.env['ir.config_parameter'].set_param('mail.catchall.domain', 'schlouby.fr') self.test_channel.write({'email_send': True}) - self._join_channel(self.test_channel, self.user_employee.partner_id | self.test_partner) + + # Subscribe an user without email. We shouldn't try to send email to them. + nomail = self.env['res.users'].create({ + "login": "nomail", + "name": "No Mail", + "email": False, + "notification_type": "email", + }) + self._join_channel(self.test_channel, self.user_employee.partner_id | self.test_partner | nomail.partner_id) self.test_channel.message_post(body="Test", message_type='comment', subtype='mt_comment') self.assertEqual(len(self._mails), 1)