From 8eb2c5b24997eee735b0f0a7340ae21a383c012f Mon Sep 17 00:00:00 2001 From: resteve Date: Thu, 7 Apr 2016 18:59:20 +0200 Subject: [PATCH] Use new sendmail module --- dunning.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/dunning.py b/dunning.py index b979b84..a4c8320 100644 --- a/dunning.py +++ b/dunning.py @@ -3,7 +3,7 @@ # the full copyright notices and license terms. from trytond.pool import Pool, PoolMeta from trytond.transaction import Transaction -from trytond.tools import get_smtp_server +from trytond.sendmail import sendmail from email.mime.text import MIMEText from email.header import Header import logging @@ -83,11 +83,4 @@ class Dunning: msg['From'] = from_addr msg['Subject'] = Header(subject, 'utf-8') - try: - server = get_smtp_server() - server.sendmail(from_addr, ', '.join(to_addr), msg.as_string()) - server.quit() - except Exception, exception: - logger.info( - 'Unable to deliver email (%s):\n %s' - % (exception, msg.as_string())) + sendmail(from_addr, to_addr, msg)