[FIX] mail: less confusing To: header for mailing-list posts
Many mail clients will replace the name in the To: header with Me if the To: email matches the email of the user. These users will see To: Me instead of "Followers of ..." and usually believe this was a private email from the sender to them. But when replying they would reply to the whole list. Fix this by explicitly forcing the To: to be the mailing list address.
This commit is contained in:
@@ -221,12 +221,13 @@ class mail_group(osv.Model):
|
||||
def message_get_email_values(self, cr, uid, id, notif_mail=None, context=None):
|
||||
res = super(mail_group, self).message_get_email_values(cr, uid, id, notif_mail=notif_mail, context=context)
|
||||
group = self.browse(cr, uid, id, context=context)
|
||||
res.update({
|
||||
'headers': {
|
||||
'Precedence': 'list',
|
||||
}
|
||||
})
|
||||
headers = res.setdefault('headers', {})
|
||||
headers['Precedence'] = 'list'
|
||||
if group.alias_domain:
|
||||
res['headers']['List-Id'] = '%s.%s' % (group.alias_name, group.alias_domain)
|
||||
res['headers']['List-Post'] = '<mailto:%s@%s>' % (group.alias_name, group.alias_domain)
|
||||
headers['List-Id'] = '%s.%s' % (group.alias_name, group.alias_domain)
|
||||
headers['List-Post'] = '<mailto:%s@%s>' % (group.alias_name, group.alias_domain)
|
||||
# Avoid users thinking it was a personal message
|
||||
# X-Forge-To: will replace To: after SMTP envelope is determined by ir.mail.server
|
||||
list_to = '"%s" <%s@%s>' % (group.name, group.alias_name, group.alias_domain)
|
||||
headers['X-Forge-To'] = list_to
|
||||
return res
|
||||
|
||||
@@ -415,6 +415,13 @@ class ir_mail_server(osv.osv):
|
||||
smtp_to_list = filter(None, tools.flatten(map(extract_rfc2822_addresses,[email_to, email_cc, email_bcc])))
|
||||
assert smtp_to_list, "At least one valid recipient address should be specified for outgoing emails (To/Cc/Bcc)"
|
||||
|
||||
x_forge_to = message['X-Forge-To']
|
||||
if x_forge_to:
|
||||
# `To:` header forged, e.g. for posting on mail.groups, to avoid confusion
|
||||
del message['X-Forge-To']
|
||||
del message['To'] # avoid multiple To: headers!
|
||||
message['To'] = x_forge_to
|
||||
|
||||
# Do not actually send emails in testing mode!
|
||||
if getattr(threading.currentThread(), 'testing', False):
|
||||
_test_logger.info("skip sending email in test mode")
|
||||
|
||||
Reference in New Issue
Block a user