Esempio n. 1
0
 public static final Transport getMailTransport(StaticConfig staticConfig)
     throws MessagingException {
   Session mailSession = Session.getDefaultInstance(getMailInfo(staticConfig));
   Transport transport = mailSession.getTransport("smtp");
   transport.connect(
       staticConfig.getSMTPHost(),
       staticConfig.getSMTPUser(),
       staticConfig.getSMTPPasswordParam());
   return transport;
 }
Esempio n. 2
0
  private void updateInfo(StaticConfig staticConfig) {
    Properties finalProps = new Properties();

    if (staticConfig.getSMTPHost() != null) {
      finalProps.put(SMTP_HOST_PARAM, staticConfig.getSMTPHost());
    }
    if (staticConfig.getSMTPPort() != null) {
      finalProps.put(SMTP_PORT_PARAM, staticConfig.getSMTPPort());
    }
    if (staticConfig.getSMTPUser() != null) {
      finalProps.put(SMTP_USER_PARAM, staticConfig.getSMTPUser());
    }
    if (staticConfig.getSMTPPasswordParam() != null) {
      finalProps.put(SMTP_PASSWORD_PARAM, staticConfig.getSMTPPasswordParam());
    }

    this.tempDir = staticConfig.getTempDir();

    this.props = finalProps;
  }
Esempio n. 3
0
  private static Properties getMailInfo(StaticConfig staticConfig) {
    Properties finalProps = new Properties();

    if (staticConfig != null) {
      if (staticConfig.getSMTPHost() != null) {
        finalProps.put(MailService.SMTP_HOST_PARAM, staticConfig.getSMTPHost());
      }
      if (staticConfig.getSMTPPort() != null) {
        finalProps.put(MailService.SMTP_PORT_PARAM, staticConfig.getSMTPPort());
      }
      if (staticConfig.getSMTPUser() != null) {
        finalProps.put(MailService.SMTP_USER_PARAM, staticConfig.getSMTPUser());
      }
      if (staticConfig.getSMTPPasswordParam() != null) {
        finalProps.put(MailService.SMTP_PASSWORD_PARAM, staticConfig.getSMTPPasswordParam());
      }
    } else {
      finalProps.put(MailService.SMTP_HOST_PARAM, "localhost");
      finalProps.put(MailService.SMTP_PORT_PARAM, 25);
    }

    return finalProps;
  }