diff options
Diffstat (limited to 'addons/mail/models/mail_thread.py')
| -rw-r--r-- | addons/mail/models/mail_thread.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 91b41a15594..fe3c5b98194 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -842,15 +842,20 @@ class MailThread(models.AbstractModel): record_set = None def _create_bounce_email(): - self.env['mail.mail'].create({ + bounce_to = decode_header(message, 'Return-Path') or email_from + bounce_mail_values = { 'body_html': '<div><p>Hello,</p>' '<p>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.</p></div>' '<blockquote>%s</blockquote>' % (message.get('to'), message_dict.get('body')), 'subject': 'Re: %s' % message.get('subject'), - 'email_to': message.get('from'), + 'email_to': bounce_to, 'auto_delete': True, - }).send() + } + bounce_from = self.env['ir.mail_server']._get_default_bounce_address() + if bounce_from: + bounce_mail_values['email_from'] = 'MAILER-DAEMON <%s>' % bounce_from + self.env['mail.mail'].create(bounce_mail_values).send() def _warn(message): _logger.info('Routing mail with Message-Id %s: route %s: %s', |
