@Signature public PHtmlEmail setCharset(String charset) { htmlEmail.setCharset(charset); return this; }
public static void sendSimpleEmail(String emails, String subject, String message, boolean initializeEmail) throws EmailException { if (initializeEmail) { initializeEmail(AppProperties.getInstance().getEmailSettings()); } email.setCharset("UTF-8"); email.setSubject(subject); email.setHtmlMsg(message); email.addTo(emails.split(",")); String sendReturn = email.send(); _logger.debug("Send Status:[{}]", sendReturn); _logger.debug("EmailSettings successfully sent to [{}], Message:[{}]", emails, message); }
public static void sendSimpleEmail(String emails, String subject, String message, boolean initializeEmail) throws EmailException { if (initializeEmail) { initializeEmail(AppProperties.getInstance().getEmailSettings()); } email.setCharset("UTF-8"); email.setSubject(subject); email.setHtmlMsg(message); email.addTo(emails.split(",")); String sendReturn = email.send(); _logger.debug("Send Status:[{}]", sendReturn); _logger.debug("EmailSettings successfully sent to [{}], Message:[{}]", emails, message); }
private boolean send(String title, String content, List<String> receivers) { try { HtmlEmail email = new HtmlEmail(); email.setAuthentication(Configuration.MAIL_SENDER_USERNAME, Configuration.MAIL_SENDER_PASSWORD); email.setHostName(Configuration.MAIL_SENDER_SMTP_HOST); email.setSmtpPort(Configuration.MAIL_SENDER_SMTP_PORT); email.setFrom(Configuration.MAIL_SENDER_USERNAME, Configuration.MAIL_SENDER_NAME); email.setSubject(title); email.setHtmlMsg(content); email.addTo(receivers.stream().toArray(String[]::new)); email.setCharset("UTF-8"); email.setSSLOnConnect(false); email.send(); logger.info("send mail to {} success", JSON.toJSONString(receivers)); return true; } catch (Exception e) { logger.error("send mail to {} fail, caused by", JSON.toJSONString(receivers), e); return false; } } }
email.setSmtpPort(ssLPort); email.setSSL(true); email.setCharset("utf8"); email.addTo(sendTo); email.setFrom(sendFrom);
public HtmlEmail buildHtmlEmail(String emailAddress, String displayName) throws Exception { HashMap<String, String> configMap = acqConifMap(); String hostName = configMap.get(EmailItemEnum.EMAIL_HOST.getItemKey()); String userName = configMap.get(EmailItemEnum.EMAIL_USERNAME.getItemKey()); String userPwd = configMap.get(EmailItemEnum.EMAIL_PWD.getItemKey()); // Create the email message HtmlEmail email = new HtmlEmail(); email.setAuthentication(userName, userPwd); email.setHostName(hostName); email.addTo(emailAddress, displayName); email.setFrom("msg@51xianqu.net", "CMDB"); email.setSubject("工单消息~"); email.setCharset("UTF-8"); // set the alternative message email.setTextMsg("Your email client does not support HTML messages"); return email; }
private HtmlEmail createNewEmail(final SessionInfo session) throws EmailException { final HtmlEmail email = new HtmlEmail(); email.setCharset(Defaults.CHARSET.displayName()); // otherwise the e-mail contents are mangled email.setHostName(getSmtpHostname()); email.setSmtpPort(getSmtpPort()); email.setStartTLSRequired(isStartTlsRequired()); email.setSSLOnConnect(isSslOnConnectRequired()); if (isAuthenticationRequired()) { final String username = getSmtpUsername(); LOGGER.debug("Will contact SMTP server as '{}'.", username); email.setAuthentication(getSmtpUsername(), getSmtpPassword()); } else { LOGGER.debug("Will contact SMTP server anonymously."); } email.setFrom(getSender(), session.getName()); email.addTo(getRecipient()); return email; }
private HtmlEmail createNewEmail(final SessionInfo session) throws EmailException { final HtmlEmail email = new HtmlEmail(); email.setCharset(Defaults.CHARSET.displayName()); // otherwise the e-mail contents are mangled email.setHostName(getSmtpHostname()); email.setSmtpPort(getSmtpPort()); email.setStartTLSRequired(isStartTlsRequired()); email.setSSLOnConnect(isSslOnConnectRequired()); if (isAuthenticationRequired()) { final String username = getSmtpUsername(); LOGGER.debug("Will contact SMTP server as '{}'.", username); email.setAuthentication(getSmtpUsername(), getSmtpPassword()); } else { LOGGER.debug("Will contact SMTP server anonymously."); } email.setFrom(getSender(), session.getName()); email.addTo(getRecipient()); return email; }
if (smtpUser != null) email.setAuthentication(smtpUser, mailSetting.getSmtpPassword()); email.setCharset(CharEncoding.UTF_8);
public boolean send(String to, String subject, String templateFile, Map<String, Object> root) { try { HtmlEmail email = ioc.get(HtmlEmail.class); email.setCharset("UTF-8"); email.setSubject(subject); email.setHtmlMsg(processTemplateIntoString(templateFile, root)); email.addTo(to); String res = email.send(); if (log.isDebugEnabled()) { log.debug(res); } return true; } catch (Exception e) { log.error("send email fail", e); return false; } }