本文整理汇总了Java中org.simplejavamail.mailer.config.ServerConfig类的典型用法代码示例。如果您正苦于以下问题:Java ServerConfig类的具体用法?Java ServerConfig怎么用?Java ServerConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerConfig类属于org.simplejavamail.mailer.config包,在下文中一共展示了ServerConfig类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initMailer
import org.simplejavamail.mailer.config.ServerConfig; //导入依赖的package包/类
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));
}
示例2: writeReport
import org.simplejavamail.mailer.config.ServerConfig; //导入依赖的package包/类
/**
* {@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");
}
示例3: start
import org.simplejavamail.mailer.config.ServerConfig; //导入依赖的package包/类
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);
}
示例4: sendMail
import org.simplejavamail.mailer.config.ServerConfig; //导入依赖的package包/类
@Override
public void sendMail() {
new Mailer( new ServerConfig("smtp.host.com", 587),
TransportStrategy.SMTP_TLS
).sendMail(email);
}
示例5: sendMail
import org.simplejavamail.mailer.config.ServerConfig; //导入依赖的package包/类
@Override
public void sendMail() {
new Mailer(new ServerConfig("smtp.host.com", 587), TransportStrategy.SMTP_TLS).sendMail(email);
}