mail['Return-Path'] = conf.get('mail', 'admin')
mail['X-Mailer'] = 'sercom ' + sercom.VERSION
mail['X-Priority'] = '5'
- smtp = smtplib.SMTP(conf.get('mail', 'smtp'))
- smtp.sendmail(mail['From'], mail['To'], mail.as_string())
- smtp.close()
+ sent = False
+ while not sent:
+ try:
+ smtp = smtplib.SMTP(conf.get('mail', 'smtp'))
+ smtp.sendmail(mail['From'], mail['To'], mail.as_string())
+ smtp.close()
+ sent = True
+ except smtplib.SMTPException, e:
+ log.warning('No se pudo enviar el mail a %s (%s)',
+ inscripto.padron, inscripto.mail)
+ time.sleep(1)
# Inicializo
conf, conn, log = sercom.init('deliver')