コード例 #1
0
ファイル: MailService.java プロジェクト: muh6mm3d/javlo
 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;
 }
コード例 #2
0
ファイル: MailService.java プロジェクト: muh6mm3d/javlo
  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;
  }
コード例 #3
0
ファイル: MailService.java プロジェクト: muh6mm3d/javlo
  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;
  }