@Override public Result check() { try { javaMailSender.getSession().getTransport().connect(); return Result.healthy(); } catch (MessagingException e) { log.debug("Cannot connect to e-mail server: {}", e); return Result.unhealthy("Cannot connect to e-mail server"); } }
@Override public Result check() { try { javaMailSender .getSession() .getTransport() .connect( javaMailSender.getHost(), javaMailSender.getUsername(), javaMailSender.getPassword()); return Result.healthy(); } catch (Exception e) { log.debug("Cannot connect to e-mail server: {}", e); return Result.unhealthy("Cannot connect to e-mail server"); } }
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { log.debug("Initializing JavaMail health indicator"); try { javaMailSender .getSession() .getTransport() .connect( javaMailSender.getHost(), javaMailSender.getPort(), javaMailSender.getUsername(), javaMailSender.getPassword()); builder.up(); } catch (MessagingException e) { log.debug("Cannot connect to e-mail server. Error: {}", e.getMessage()); builder.down(e); } }