Merge lp:~therp-nl/openobject-server/7.0-lp1299132-check_smtp_sendmail_return_value into lp:openobject-server/7.0

Proposed by Stefan Rijnhart (Opener) on 2014-03-28
Status: Needs review
Proposed branch: lp:~therp-nl/openobject-server/7.0-lp1299132-check_smtp_sendmail_return_value
Merge into: lp:openobject-server/7.0
Diff against target: 19 lines (+8/-1)
1 file modified
openerp/addons/base/ir/ir_mail_server.py (+8/-1)
To merge this branch: bzr merge lp:~therp-nl/openobject-server/7.0-lp1299132-check_smtp_sendmail_return_value
Reviewer Review Type Date Requested Status
OpenERP Core Team 2014-03-28 Pending
Review via email: mp+213327@code.launchpad.net

Description of the change

Signal failed recipients as returned by smtp.sendmail. The exception is crafted taking into account that the outer try block rehashes its contents into a MailDeliveryException.

To post a comment you must log in.

Unmerged revisions

5268. By Stefan Rijnhart (Opener) on 2014-03-28

[FIX] Check return value of smtp.sendmail containing failed recipients

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/ir/ir_mail_server.py'
2--- openerp/addons/base/ir/ir_mail_server.py 2013-09-18 14:38:07 +0000
3+++ openerp/addons/base/ir/ir_mail_server.py 2014-03-28 19:40:55 +0000
4@@ -460,7 +460,14 @@
5
6 try:
7 smtp = self.connect(smtp_server, smtp_port, smtp_user, smtp_password, smtp_encryption or False, smtp_debug)
8- smtp.sendmail(smtp_from, smtp_to_list, message.as_string())
9+ refused = smtp.sendmail(
10+ smtp_from, smtp_to_list, message.as_string())
11+ if refused:
12+ raise osv.except_osv(
13+ _("Mail did not reach the following recipients:"),
14+ '\n'.join(["%s: %s" % (
15+ tools.ustr(recipient), tools.ustr(error))
16+ for recipient, error in refused.iteritems()]))
17 finally:
18 try:
19 # Close Connection of SMTP Server