当前位置: 首页>>代码示例>>Java>>正文


Java TransportStrategy.SMTP_TLS属性代码示例

本文整理汇总了Java中org.simplejavamail.mailer.config.TransportStrategy.SMTP_TLS属性的典型用法代码示例。如果您正苦于以下问题:Java TransportStrategy.SMTP_TLS属性的具体用法?Java TransportStrategy.SMTP_TLS怎么用?Java TransportStrategy.SMTP_TLS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.simplejavamail.mailer.config.TransportStrategy的用法示例。


在下文中一共展示了TransportStrategy.SMTP_TLS属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initMailer

private void initMailer() {

        String host = appConfig.get(CONFIG_KEY_SMTP_HOST, "");
        int port = appConfig.getInt(CONFIG_KEY_SMTP_PORT, 465);
        String secure = appConfig.get(CONFIG_KEY_SMTP_SECURE, "tls");
        String username = appConfig.get(CONFIG_KEY_SMTP_USERNAME, "");
        String password = appConfig.get(CONFIG_KEY_SMTP_PASS, "");

        TransportStrategy transportStrategy = TransportStrategy.SMTP_PLAIN;
        if (secure.toLowerCase().equals("tls")) {

            transportStrategy = TransportStrategy.SMTP_TLS;
        } else if (secure.toLowerCase().equals("ssl")) {

            transportStrategy = TransportStrategy.SMTP_SSL;
        }

        mailer = new Mailer(new ServerConfig(host, port, username, password), transportStrategy);
        mailer.setSessionTimeout(30000);
//        mailer.setDebug(appConfig.getBool(CONFIG_KEY_APP_DEV_MODE, false));
    }
 
开发者ID:thundernet8,项目名称:Elune,代码行数:21,代码来源:MailMQServiceImpl.java

示例2: writeReport

/**
 * {@inheritDoc}
 * <p>
 * Render the report HTML using Jtwig and send the result to the recipient emails.
 */
@Override
public void writeReport(List<TestSuite> testSuites) throws IOException {
    if (testSuites == null) {
        testSuites = Collections.emptyList();
    }
    log.info("Sending report email for {} test suites", testSuites.size());
    List<TestSuiteModel> testList = new ArrayList<>(testSuites.size());
    boolean hasError = false;
    for (TestSuite testSuite : testSuites) {
        TestSuiteModel testSuiteModel = new TestSuiteModel(testSuite);
        hasError = hasError || !testSuiteModel.allPassed();
        testList.add(testSuiteModel);
    }
    JtwigTemplate template = JtwigTemplate.classpathTemplate("templates/email.twig");
    JtwigModel model = JtwigModel.newModel()
                                 .with("error", hasError)
                                 .with("testList", testList);
    String reportHtml = template.render(model);
    EmailBuilder emailBuilder = new EmailBuilder().from(senderName, fromEmail)
                                                  .replyTo(senderName, replyTo)
                                                  .subject("Validatar Report – " + (hasError ? "Test Errors" : "Tests Passed"))
                                                  .addHeader("X-Priority", 2)
                                                  .textHTML(reportHtml);
    for (String recipientEmail : recipientEmails) {
        emailBuilder.to(recipientEmail);
    }
    Email reportEmail = emailBuilder.build();
    ServerConfig mailServerConfig = new ServerConfig(smtpHost, smtpPort);
    Mailer reportMailer = new Mailer(mailServerConfig, TransportStrategy.SMTP_TLS);
    sendEmail(reportMailer, reportEmail);
    log.info("Finished sending report to recipients");
}
 
开发者ID:yahoo,项目名称:validatar,代码行数:37,代码来源:EmailFormatter.java

示例3: start

public void start() {
  mailer = new Mailer(
      new ServerConfig(
          Configuration.i.getSmtp().getHost(),
          Configuration.i.getSmtp().getPort(),
          Configuration.i.getSmtp().getUserName(),
          Configuration.i.getSmtp().getPassword()),
      TransportStrategy.SMTP_TLS);

  Properties props = new Properties();
  props.put("mail.smtp.localhost", "codeka.com.au");
  mailer.applyProperties(props);
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:13,代码来源:SmtpHelper.java

示例4: MailService

private MailService() {
    mailer = new Mailer(Config.getCatalog().mail.server, Config.getCatalog().mail.port, Config.getCatalog().mail.user, Config.getCatalog().mail.password, TransportStrategy.SMTP_TLS);
    mailer.setDebug(false);
    mailer.trustAllSSLHosts(true);
}
 
开发者ID:Twasi,项目名称:twasi-core,代码行数:5,代码来源:MailService.java


注:本文中的org.simplejavamail.mailer.config.TransportStrategy.SMTP_TLS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。