← Back to team overview

openerp-community team mailing list archive

Re: E-Mail sending problems and questions about addons/mail/mail_mail.py

 

Quoting "Eric Caudal" <eric.caudal@xxxxxxxxxxxxxx>:
Not sure here because of the use of aliases (which links several emails into one for OE but that your SMTP server has no clue).

Sorry, I'm not very familiar with the concept of aliases. How do
they influence the fact, that one message results in many emails?

But even if the multiple emails were intentional (I hope not!),
the other points (no warning on failed sending of email, no further
email after first fail, probably wrong usage of variable `res`) are
bugs, right?

Cheers


On 11/27/2013 07:08 PM, W. Martin Borgert wrote:
[version 7.0-20131126-00264]

I came across a problem with email sending. When adding a message to a
project issue, only the first five followers got an email. There was
no error message in the web user interface, instead the user interface
shows, that the email has been send to all followers.

What happened?

1. Instead of sending one email per message, one email per recipient
   is generated, in my case ten emails instead of one. This is wrong
   IMHO, because it is the task of the SMTP server to distribute the
   emails to all recipients. This is the main problem, I assume.

2. The emails are delivered to the SMTP server, which throttles the
   traffic by not allowing more than five emails that fast. This leads
   to an in addons/base/ir/ir_mail_server.py:464 The exception is
   logged but invisible to the web interface user:
   SMTPServerDisconnted("Connection unexpectedly closed")

3. The email iteration stops at that point, no further emails are
   tried for this message. If it not were for throttling, IMHO this
   again is wrong. One should at least try to sent out all emails.

4. Independent of this doubts, I assume, that the actual loop sending
   out the email is not correct: A return value is saved inside the
   loop in `res` and used after the loop, i.e. the value is just
   overwritten and only the last value is used.

From addons/mail/mail_mail.py:

283 email_list = []
284 if recipient_ids:
285     for partner in self.pool.get('res.partner').browse(...
286         email_list.append(self.send_get_email_dict(...
287 else:
288     email_list.append(self.send_get_email_dict(...
...
291 res = None
292 for email in email_list:
293     msg = ir_mail_server.build_email(
294         email_from = mail.email_from,
295         email_to = email.get('email_to'),
...
307     res = ir_mail_server.send_email(cr, uid, msg,
308         mail_server_id=mail.mail_server_id.id, context=context)
309 if res:
310     mail.write({'state': 'sent', 'message_id': res})
311     mail_sent = True
312 else:
313     mail.write({'state': 'exception'})
314     mail_sent = False

IMHO, using the loop in line 292 is wrong. Instead one message should be
send out with the correct list of recipients, right?

Thanks in advance for any enlightenment!



Follow ups

References