コード例 #1
0
ファイル: ContaEmail.java プロジェクト: aricomputacao/SGPO
  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();
  }
コード例 #2
0
 @Override
 public void sendEmail() {
   try {
     simpleEmail.send();
   } catch (EmailException e) {
     throw new FailedNotificationException(e);
   }
 }
コード例 #3
0
 @Override
 public void send() {
   try {
     simpleEmail.send();
   } catch (EmailException e) {
     System.out.println("Email send error " + e);
   }
 }
コード例 #4
0
ファイル: Email.java プロジェクト: chaice/inte_code
 /**
  * @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();
   }
 }
コード例 #5
0
ファイル: EmailUtils.java プロジェクト: GeneMANIA/genemania
 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();
   }
 }
コード例 #6
0
ファイル: SendMail.java プロジェクト: yubin1030/cxdai_portal
  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();
    }
  }
コード例 #7
0
  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);
    }
  }
コード例 #8
0
ファイル: SendMail.java プロジェクト: nubiofreitas/Login
  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();
    }
  }