@SuppressWarnings("rawtypes") private static boolean sendMail(int messageType, String host, String user, String passwd, String subject, String message, String... to) { try { Email mail = Email.create() .from(user).to(to) .subject(subject); switch (messageType) { case HTML_TYPE: mail.addHtml(message); break; case TEXT_TYPE: default: mail.addText(message); break; } SmtpServer smtpServer = SmtpServer.create(host).authenticateWith(user, passwd); SendMailSession session = smtpServer.createSession(); session.open(); session.sendMail(mail); session.close(); return true; } catch (Exception e) { logger.warn(e.getMessage(), e); return false; } }