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


Java Mailer类代码示例

本文整理汇总了Java中org.simplejavamail.mailer.Mailer的典型用法代码示例。如果您正苦于以下问题:Java Mailer类的具体用法?Java Mailer怎么用?Java Mailer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: initMailer

import org.simplejavamail.mailer.Mailer; //导入依赖的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));
    }
 
开发者ID:thundernet8,项目名称:Elune,代码行数:22,代码来源:MailMQServiceImpl.java

示例2: main

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    clearConfigProperties();

    final Email emailNormal = new Email();
    emailNormal.setFromAddress("lollypop", "[email protected]");
    // don't forget to add your own address here ->
    emailNormal.addRecipient("C.Cane", YOUR_GMAIL_ADDRESS, RecipientType.TO);
    emailNormal.setText("We should meet up!");
    emailNormal.setTextHTML("<b>We should meet up!</b><img src='cid:thumbsup'>");
    emailNormal.setSubject("hey");

    // add two text files in different ways and a black thumbs up embedded image ->
    emailNormal.addAttachment("dresscode.txt", new ByteArrayDataSource("Black Tie Optional", "text/plain"));
    emailNormal.addAttachment("location.txt", "On the moon!".getBytes(Charset.defaultCharset()), "text/plain");
    String base64String = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABeElEQVRYw2NgoAAYGxu3GxkZ7TY1NZVloDcAWq4MxH+B+D8Qv3FwcOCgtwM6oJaDMTAUXOhmuYqKCjvQ0pdoDrCnmwNMTEwakC0H4u8GBgYC9Ap6DSD+iewAoIPm0ctyLqBlp9F8/x+YE4zpYT8T0LL16JYD8U26+B7oyz4sloPwenpYno3DchCeROsUbwa05A8eB3wB4kqgIxOAuArIng7EW4H4EhC/B+JXQLwDaI4ryZaDSjeg5mt4LCcFXyIn1fdSyXJQVt1OtMWGhoai0OD8T0W8GohZifE1PxD/o7LlsPLiFNAKRrwOABWptLAcqc6QGDAHQEOAYaAc8BNotsJAOgAUAosG1AFA/AtUoY3YEFhKMAvS2AE7iC1+WaG1H6gY3gzE36hUFJ8mqzbU1dUVBBqQBzTgIDQRkWo5qCZdpaenJ0Zx1aytrc0DDB0foIG1oAYKqC0IZK8D4n1AfA6IzwPxXpCFoGoZVEUDaRGGUTAKRgEeAAA2eGJC+ETCiAAAAABJRU5ErkJggg==";
    emailNormal.addEmbeddedImage("thumbsup", parseBase64Binary(base64String), "image/png");

    // let's try producing and then consuming a MimeMessage ->
    final MimeMessage mimeMessage = Mailer.produceMimeMessage(emailNormal);
    final Email emailFromMimeMessage = new Email(mimeMessage);

    // note: the following statements will produce 6 new emails!
    sendMail(emailNormal);
    sendMail(emailFromMimeMessage); // should produce the exact same result as emailNormal!
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:26,代码来源:MailTestApp.java

示例3: mailConfig

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Bean(name = "mailSender")
public Mailer mailConfig(){
    if (mailServerConfig == null) {
        synchronized (GenericConfig.class) {
            if (mailServerConfig == null) {
                mailServerConfig = new ServerConfig(host, port, from, password);
            }
        }
    }
    return new Mailer(mailServerConfig);
}
 
开发者ID:QianWorks,项目名称:qianworks-meican,代码行数:12,代码来源:GenericConfig.java

示例4: initializeMailer

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
private static Mailer initializeMailer(Config config) {
	ConfigLoader.loadProperties(
		// Properties are in ISO 8859 1
		new ByteArrayInputStream(readMailConfiguration(config).getBytes(StandardCharsets.ISO_8859_1)),
		true
	);

	return new Mailer();
}
 
开发者ID:Coreoz,项目名称:Plume,代码行数:10,代码来源:MailerProvider.java

示例5: writeReport

import org.simplejavamail.mailer.Mailer; //导入依赖的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");
}
 
开发者ID:yahoo,项目名称:validatar,代码行数:38,代码来源:EmailFormatter.java

示例6: testSendEmail

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Test
public void testSendEmail() {
    Mailer mailer = mock(Mailer.class);
    Email email = mock(Email.class);
    EmailFormatter formatter = new EmailFormatter();
    formatter.sendEmail(mailer, email);
    verify(mailer).sendMail(email);
}
 
开发者ID:yahoo,项目名称:validatar,代码行数:9,代码来源:EmailFormatterTest.java

示例7: buildMailer

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
private static final Mailer buildMailer(String host, int port, String gMailAddress, String gMailPassword, TransportStrategy strategy) {
	return MailerBuilder
			.withSMTPServer(host, port, gMailAddress, gMailPassword)
			.withTransportStrategy(strategy)
			.withTransportModeLoggingOnly(LOGGING_MODE)
			.buildMailer();
}
 
开发者ID:bbottema,项目名称:simple-java-mail,代码行数:8,代码来源:MailTestDemoApp.java

示例8: start

import org.simplejavamail.mailer.Mailer; //导入依赖的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);
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:14,代码来源:SmtpHelper.java

示例9: sendMail

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Override
public void sendMail() {
	new Mailer( new ServerConfig("smtp.host.com", 587),
                   TransportStrategy.SMTP_TLS
                   ).sendMail(email);
}
 
开发者ID:maugern,项目名称:jersey-skeleton,代码行数:7,代码来源:ConfirmationMail.java

示例10: sendMail

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Override
public void sendMail() {
	new Mailer(new ServerConfig("smtp.host.com", 587), TransportStrategy.SMTP_TLS).sendMail(email);
}
 
开发者ID:maugern,项目名称:jersey-skeleton,代码行数:5,代码来源:NewPasswordMail.java

示例11: MailService

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
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,代码行数:6,代码来源:MailService.java

示例12: getMailer

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
public Mailer getMailer() {
    return mailer;
}
 
开发者ID:Twasi,项目名称:twasi-core,代码行数:4,代码来源:MailService.java

示例13: MailServerHealthCheck

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
public MailServerHealthCheck(final Mailer mailer) {
    this.mailer = mailer;
}
 
开发者ID:msteinhoff,项目名称:dropwizard-smtp-mail,代码行数:4,代码来源:MailServerHealthCheck.java

示例14: sendMail

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
private static void sendMail(final Email email) {
    ProxyConfig proxyconfig = new ProxyConfig("", 8080, "", "");
    new Mailer(serverConfigSMTP, TransportStrategy.SMTP_TLS, proxyconfig).sendMail(email);
    new Mailer(serverConfigTLS, TransportStrategy.SMTP_TLS, proxyconfig).sendMail(email);
    new Mailer(serverConfigSSL, TransportStrategy.SMTP_SSL).sendMail(email);
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:7,代码来源:MailTestApp.java

示例15: configure

import org.simplejavamail.mailer.Mailer; //导入依赖的package包/类
@Override
protected void configure() {
	bind(Mailer.class).toProvider(MailerProvider.class);
}
 
开发者ID:Coreoz,项目名称:Plume,代码行数:5,代码来源:GuiceMailModule.java


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