Ejemplo n.º 1
0
  public boolean sendMultipartMail(final MailOption mailOption) {
    try {
      Properties props = System.getProperties();
      props.put("mail.transport.protocol", "smtp");
      // props.put("mail.smtp.host", "smtp.gmail.com");
      props.put("mail.smtp.host", "smtp.bcel.com.la");
      props.put("mail.smtp.port", "25");
      props.put("mail.smtp.auth", "true");
      props.put("mail.smtp.starttls.enable", "true");
      props.put("mail.smtp.starttls.required", "true");

      // Session session = Session.getInstance(props, null);

      Session session =
          Session.getDefaultInstance(
              props,
              new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                  // return new PasswordAuthentication("dineshvgsmadurai","VGS@1234");
                  return new PasswordAuthentication("*****@*****.**", "bcel@123");
                }
              });

      try {
        MimeMessage msg = new MimeMessage(session);

        System.out.println("mailOption : " + mailOption.getTo()[0]);

        // msg.setFrom(new InternetAddress("*****@*****.**"));
        msg.setFrom(new InternetAddress("*****@*****.**"));
        msg.setRecipient(Message.RecipientType.TO, new InternetAddress(mailOption.getTo()[0]));
        msg.setSubject(mailOption.getSubject());
        msg.setContent(mailOption.getMultipart());

        Transport.send(msg);

      } catch (MessagingException e) {
        e.printStackTrace();
      }

    } catch (Exception e) {

    }
    return true;
  }
Ejemplo n.º 2
0
  public void sendMultipartEmailWithForCase(
      String[] clinicalEmailIds, String ccEmail, Multipart bodyContent)
      throws AddressException, MessagingException {

    MailOption mailOption = new MailOption();
    mailOption.setForceSystemConfiguredSender(true);
    mailOption.setAuthenticate(true);
    mailOption.setTo(clinicalEmailIds);
    mailOption.setCc(new String[] {ccEmail});
    mailOption.setSubject("Welcome to SPAY!");
    mailOption.setMultipart(bodyContent);
    sendMultipartMail(mailOption);
  }