コード例 #1
0
 private void sendNotificationEmail(User user) {
   try {
     Map<String, Object> model = new TreeMap<String, Object>();
     model.put("user", user);
     notifyEmailSender.sendEmail(model);
   } catch (Exception e) {
     log.warn("Unable to send email to " + notifyEmailSender.getToEmail(), e);
   }
 }
コード例 #2
0
ファイル: DataSource.java プロジェクト: BerengereG/contrib
  private void sendEmail(Task.Status exitStatus, File logFile)
      throws IOException, MessagingException, TemplateException {
    String smtpServer = RepoxContextUtil.getRepoxManager().getConfiguration().getSmtpServer();
    if (smtpServer == null || smtpServer.isEmpty()) {
      return;
    }

    String fromEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getDefaultEmail();
    String recipientsEmail =
        RepoxContextUtil.getRepoxManager().getConfiguration().getAdministratorEmail();
    String adminMailPass = RepoxContextUtil.getRepoxManager().getConfiguration().getMailPassword();
    String subject = "REPOX Data Source ingesting finished. Exit status: " + exitStatus.toString();

    EmailSender emailSender = new EmailSender();
    String pathIngestFile =
        URLDecoder.decode(
            Thread.currentThread().getContextClassLoader().getResource("ingest.html.ftl").getFile(),
            "ISO-8859-1");
    emailSender.setTemplate(
        pathIngestFile.substring(0, pathIngestFile.lastIndexOf("/")) + "/ingest");

    HashMap map = new HashMap<String, String>();
    map.put("exitStatus", exitStatus.toString());
    map.put("id", id);

    JavaMailSenderImpl mail = new JavaMailSenderImpl();
    // mail.setUsername(fromEmail);
    mail.setUsername(recipientsEmail);

    mail.setPassword(adminMailPass);

    mail.setPort(25);

    Properties props = System.getProperties();

    props.put("mail.smtp.host", smtpServer);
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.auth", "true");
    mail.setJavaMailProperties(props);

    emailSender.setMailSender(mail);
    emailSender.sendEmail(recipientsEmail, fromEmail, subject, map, logFile.getAbsolutePath());
  }
コード例 #3
0
ファイル: DataSource.java プロジェクト: BerengereG/contrib
  public static void main(String[] args) throws Exception {
    String smtpServer = RepoxContextUtil.getRepoxManager().getConfiguration().getSmtpServer();
    if (smtpServer == null || smtpServer.isEmpty()) {
      return;
    }

    String fromEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getDefaultEmail();
    String recipientsEmail =
        RepoxContextUtil.getRepoxManager().getConfiguration().getAdministratorEmail();
    String adminMailPass = RepoxContextUtil.getRepoxManager().getConfiguration().getMailPassword();
    String subject = "REPOX Data Source ingesting finished. Exit status: ";

    EmailSender emailSender = new EmailSender();
    String pathIngestFile =
        URLDecoder.decode(
            Thread.currentThread().getContextClassLoader().getResource("ingest.html.ftl").getFile(),
            "ISO-8859-1");
    emailSender.setTemplate(
        pathIngestFile.substring(0, pathIngestFile.lastIndexOf("/")) + "/ingest");

    HashMap map = new HashMap<String, String>();
    map.put("exitStatus", "OK");
    map.put("id", "1111");

    JavaMailSenderImpl mail = new JavaMailSenderImpl();
    mail.setUsername(recipientsEmail);
    mail.setPassword(adminMailPass);

    mail.setPort(25);

    Properties props = System.getProperties();

    props.put("mail.smtp.host", smtpServer);
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.auth", "false");
    mail.setJavaMailProperties(props);

    emailSender.setMailSender(mail);
    emailSender.sendEmail(
        recipientsEmail, fromEmail, subject, map, "C:\\Users\\GPedrosa\\Desktop\\indexSec.txt");
  }