cubicweb/cwconfig.py
changeset 12709 280c9db41038
parent 12578 d06a2feae373
parent 12659 a422eeca6994
child 12722 1a5eb9a9f5b4
equal deleted inserted replaced
12696:eb83daa69495 12709:280c9db41038
  1241             try:
  1241             try:
  1242                 smtp = SMTP(server, port)
  1242                 smtp = SMTP(server, port)
  1243             except Exception as ex:
  1243             except Exception as ex:
  1244                 self.exception("can't connect to smtp server %s:%s (%s)",
  1244                 self.exception("can't connect to smtp server %s:%s (%s)",
  1245                                server, port, ex)
  1245                                server, port, ex)
       
  1246                 if self.mode == 'test':
       
  1247                     raise
  1246                 return False
  1248                 return False
  1247             for msg, recipients in msgs:
  1249             for msg, recipients in msgs:
  1248                 try:
  1250                 try:
  1249                     smtp.sendmail(fromaddr, recipients, msg.as_string())
  1251                     smtp.sendmail(fromaddr, recipients, msg.as_string())
  1250                 except Exception as ex:
  1252                 except Exception as ex:
  1251                     self.exception("error sending mail to %s (%s)",
  1253                     self.exception("error sending mail to %s (%s)",
  1252                                    recipients, ex)
  1254                                    recipients, ex)
       
  1255                     if self.mode == 'test':
       
  1256                         raise
  1253             smtp.close()
  1257             smtp.close()
  1254         finally:
  1258         finally:
  1255             SMTP_LOCK.release()
  1259             SMTP_LOCK.release()
  1256         return True
  1260         return True
  1257 
  1261