try { email.setHostName(host); email.setSmtpPort(port); ++ if((username != null && username.trim != "") || (password != null && password.trim != "") { -- email.setAuthentication(username, password); ++ email.setAuthentication(username, password); ++ } email.setTLS(withTLS); email.setFrom(from); String[] addrs = StringUtils.split(to, '\n'); for (String addr : addrs) { email.addTo(addr); } email.setSubject(getSubject(project)); email.setMsg(getMessage(project)); email.send(); } catch (EmailException e) { throw new SonarException("Unable to send email", e); }