public void enviarEmail(List<String> destinos, String mensagem, String titulo) throws EmailException { SimpleEmail email = new SimpleEmail(); email.setHostName(this.host); // Quando a porta utilizada não é a padrão (gmail = 465) email.setSmtpPort(this.porta); // Adicione os destinatários for (String destino : destinos) { email.addTo(destino, "", "UTF-8"); } email.setSentDate(new Date()); // Configure o seu Email do qual enviará email.setFrom(this.email, this.empresa.getNome()); // Adicione um assunto email.setSubject(titulo); // Adicione a mensagem do Email email.setMsg(Jsoup.parse(mensagem).text()); // Para autenticar no servidor é necessário chamar os dois métodos abaixo email.setTLS(true); email.setSSL(true); email.setAuthentication(this.email, this.senha); email.send(); }
public static void mail() throws EmailException { SimpleEmail email = new SimpleEmail(); email.setFrom("*****@*****.**"); email.addTo("*****@*****.**"); email.setSubject("メールのテスト"); email.setMsg("メールの本文です。本文です。"); email.setContent("メールの本文です。本文です。", "text/plain; charset=ISO-2022-JP"); email.setCharset("ISO-2022-JP"); Mail.send(email); }
/** * @param username 用户名 * @param ip 用户登录时的Ip * @param time 用户登录的时间 */ public void sendEmail(String username, String ip, String time) { SimpleEmail simpleEmail = new SimpleEmail(); simpleEmail.setAuthentication("*****@*****.**", "Q2889144"); simpleEmail.setHostName("smtp.126.com"); simpleEmail.setSmtpPort(25); simpleEmail.setCharset("utf-8"); try { simpleEmail.setFrom("*****@*****.**"); simpleEmail.addTo("*****@*****.**"); simpleEmail.setMsg(time + ",用户:" + username + "在" + ip + "登录"); simpleEmail.setSubject("开会"); simpleEmail.send(); } catch (EmailException e) { e.printStackTrace(); } }
/** * 메일을 발송한다. * * <p>when 메일발송 페이지에서 발송시 * * <p>입력폼으로부터 보내는 메일주소, 받는사람 제목, 본문내용을 입력받고 {@code email} 객체에 할당한다. 메일을 발송하고 결과를 {@code sended}에 * 할당한다. {@code writeMail()} 을 통해 메일 전송여부와 오류메세지를 설정하고 메일발송 페이지로 이동한다. * * @return the result * @throws EmailException the email exception * @see {@link SiteApp#writeMail(String, boolean)} */ public static Result sendMail() throws EmailException { SimpleEmail email = new SimpleEmail(); Map<String, String[]> formData = request().body().asFormUrlEncoded(); email.setFrom(utils.HttpUtil.getFirstValueFromQuery(formData, "from")); email.setSubject(utils.HttpUtil.getFirstValueFromQuery(formData, "subject")); email.addTo(utils.HttpUtil.getFirstValueFromQuery(formData, "to")); email.setMsg(utils.HttpUtil.getFirstValueFromQuery(formData, "body")); email.setCharset("utf-8"); String errorMessage = null; boolean sended; String result = Mailer.send(email); Logger.info(">>>" + result); sended = true; return writeMail(errorMessage, sended); }
public static void sendEmail(String feedbackTo, String subject, String message) { SimpleEmail email = new SimpleEmail(); try { email.setHostName( ApplicationConfig.getInstance() .getProperty(Constants.CONFIG_PROPERTIES.FEEDBACK_EMAIL_HOST)); email.addTo(feedbackTo); email.setFrom( ApplicationConfig.getInstance().getProperty(Constants.CONFIG_PROPERTIES.FEEDBACK_FROM)); email.setSubject(subject); email.setMsg(message); email.send(); } catch (EmailException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void send() { SimpleEmail email = new SimpleEmail(); email.setTLS(TLS); // 是否TLS校验,,某些邮箱需要TLS安全校验,同理有SSL校验 email.setHostName(hostName); try { email.setFrom(sendMailAddress, sendMailAddress); email.setAuthentication(sendMailAddress, mailPassword); email.setCharset("utf-8"); // 解决中文乱码问题 email.setSubject(mailTitle); // 标题 email.setMsg(mailContent); // 内容 for (int i = 0; i < getMailAddress.length; ++i) { email.addTo(getMailAddress[i]); // 接收方 email.send(); } } catch (EmailException e) { // e.printStackTrace(); } }
static void editRecipientSimple( CommandSender sender, String emailString, RecipientAction action) { SimpleEmail email = simpleEmail.get(sender.getName()); switch (action) { case ADD: try { email.addTo(emailString); } catch (EmailException e) { sendErrorMessage(sender, e); return; } LogHelper.showInfo("emailRecipientAdd", sender); case ADD_BCC: try { email.addBcc(emailString); } catch (EmailException e) { sendErrorMessage(sender, e); return; } LogHelper.showInfo("emailRecipientAdd", sender); case ADD_CC: try { email.addCc(emailString); } catch (EmailException e) { sendErrorMessage(sender, e); return; } LogHelper.showInfo("emailRecipientAdd", sender); case DELETE: try { email = removeRecipient(email, emailString); } catch (EmailException e) { sendErrorMessage(sender, e); return; } LogHelper.showInfo("emailRecipientDeleted", sender); case LIST: sender.sendMessage(composeReadableRecipientList(email)); default: } simpleEmail.put(sender.getName(), email); }
private void enviaEmailSimples() throws RuntimeException { try { SimpleEmail email = new SimpleEmail(); email.setHostName("127.0.0.1"); email.addTo("*****@*****.**", "Gilberto"); email.setFrom("*****@*****.**", "I'm"); email.setSubject("Test -> Email simples"); email.setMsg("Test of Email by using commons-email"); email.setAuthentication("demo", "123456"); // email.setSmtpPort(465); // email.setSSL(false); // email.setTLS(false); email.send(); // after sent email wait for a pool of connection by spring integration Thread.sleep(20000); } catch (Exception e) { throw new RuntimeException(e); } }
public void enviaEmailUsuario() { FacesContext context = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession) context.getExternalContext().getSession(false); Usuario usuario = (Usuario) session.getAttribute("usuarioLogado"); SimpleEmail email = new SimpleEmail(); // email.setSSLOnConnect(true); email.setHostName("smtp-pel.lifemed.com.br"); // email.setSslSmtpPort("465"); email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator("anderson.freitas", "nub10fr31t4s")); try { email.setFrom("*****@*****.**"); email.setDebug(true); email.setSubject(getSubject()); email.setMsg(mensagem); email.addTo(remetente); email.send(); } catch (EmailException ex) { ex.printStackTrace(); } }