Emails are sent "per recipient" instead of "per message"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
1) Steps to reproduce the issue you have observed
A project issue with multiple followers exist. Add a message ("send message") to the project issue.
2) The result you observed
Multiple emails are sent, one per recipient (= followers minus the current user). Because my email server throttles the incoming emails, only half of the recipients actually got the message. There was no error message in the web user interface, however, and the message is shown as if it were sent to all followers.
3) The result you expected
Only one email should be sent out. Distributing the email to different addresses is a task of the MTA (email server), not the client.
4) The platform you are using (and browser version, if relevant)
Debian, MTA is a Microsoft product, AFAIK.
5) The OpenERP version you are using
7.0-
There is also a code problem in addons/ mail/mail_ mail.py which is related to the bug:
The variable res is assigned to inside a loop. The value is checked after the loop, so only the last value is taken into account, previous values are silently overwritten:
283 email_list = [] get('res. partner' ).browse( ... append( self.send_ get_email_ dict(.. . append( self.send_ get_email_ dict(.. . server. build_email( 'email_ to'), server. send_email( cr, uid, msg, id=mail. mail_server_ id.id, context=context) {'state' : 'sent', 'message_id': res}) {'state' : 'exception'})
284 if recipient_ids:
285 for partner in self.pool.
286 email_list.
287 else:
288 email_list.
...
291 res = None
292 for email in email_list:
293 msg = ir_mail_
294 email_from = mail.email_from,
295 email_to = email.get(
...
307 res = ir_mail_
308 mail_server_
309 if res:
310 mail.write(
311 mail_sent = True
312 else:
313 mail.write(
314 mail_sent = False
IMHO, the right fix would be to not use a loop in line 292 anyway, but sending one email per message, so res would assigned to only once in the first place.