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


Java DefaultEmail类代码示例

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


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

示例1: sendMimeEmailWithThymeleaf

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
public void sendMimeEmailWithThymeleaf() throws IOException, CannotSendEmailException, URISyntaxException {
    InlinePicture inlinePicture = createGalaxyInlinePicture();

    final Email email = DefaultEmail.builder()
            .from(new InternetAddress("[email protected]",
                    "Hari Seldon"))
            .to(newArrayList(
                    new InternetAddress("[email protected]",
                            "Cleon I")))
            .subject("You shall die! It's not me, it's Psychohistory")
            .body("")//this will be overridden by the template, anyway
            .attachment(getPdfWithAccentedCharsAttachment("Conditions_Générales_Service"))
            .encoding("UTF-8").build();

    String template = "subfolder/emailTemplate";

    Map<String, Object> modelObject = ImmutableMap.of(
            "title", "Emperor",
            "name", "Cleon I"
    );

    emailService.send(email, template, modelObject, inlinePicture);
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:24,代码来源:TestService.java

示例2: sendMimeEmailWithFreemarker

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
public void sendMimeEmailWithFreemarker() throws UnsupportedEncodingException, CannotSendEmailException, URISyntaxException {
    InlinePicture inlinePicture = createGalaxyInlinePicture();

    final Email email = DefaultEmail.builder()
            .from(new InternetAddress("[email protected]",
                    "Hari Seldon"))
            .to(newArrayList(
                    new InternetAddress("[email protected]",
                            "Cleon I")))
            .subject("You shall die! It's not me, it's Psychohistory")
            .body("")//this will be overridden by the template, anyway
            .attachment(getCsvForecastAttachment("forecast"))
            .encoding("UTF-8").build();

    String template = "emailTemplate.ftl";

    Map<String, Object> modelObject = ImmutableMap.of(
            "title", "Emperor",
            "name", "Cleon I"
    );

    emailService.send(email, template, modelObject, inlinePicture);
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:24,代码来源:TestService.java

示例3: scheduleMimeEmail

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
private void scheduleMimeEmail(OffsetDateTime when, int priority) throws UnsupportedEncodingException, CannotSendEmailException, URISyntaxException {
    InlinePicture inlinePicture = createGalaxyInlinePicture();

    final Email email = DefaultEmail.builder()
            .from(new InternetAddress("[email protected]",
                    "Hari Seldon"))
            .to(newArrayList(
                    new InternetAddress("[email protected]",
                            "Cleon I")))
            .subject(String.format("Email scheduled with firetime '%s' and priority %d", when, priority))
            .body("")//this will be overridden by the template, anyway
            .attachment(getCsvForecastAttachment("forecast"))
            .encoding("UTF-8").build();

    String template = "emailTemplate.ftl";

    Map<String, Object> modelObject = ImmutableMap.of(
            "title", "Emperor",
            "name", "Cleon I"
    );

    emailSchedulerService.schedule(email, when, priority,
            template, modelObject, inlinePicture);
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:25,代码来源:TestService.java

示例4: sendMimeEmailWithMustache

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
public void sendMimeEmailWithMustache() throws UnsupportedEncodingException, CannotSendEmailException, URISyntaxException {
    InlinePicture inlinePicture = createGalaxyInlinePicture();

    final Email email = DefaultEmail.builder()
            .from(new InternetAddress("[email protected]",
                    "Hari Seldon"))
            .to(newArrayList(
                    new InternetAddress("[email protected]",
                            "Cleon I")))
            .subject("You shall die! It's not me, it's Psychohistory")
            .body("")//this will be overridden by the template, anyway
            .attachment(getCsvForecastAttachment("forecast"))
            .encoding("UTF-8").build();

    String template = "emailTemplate.html";

    Map<String, Object> modelObject = ImmutableMap.of(
            "title", "Emperor",
            "name", "Cleon I"
    );

    emailService.send(email, template, modelObject, inlinePicture);
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:24,代码来源:TestService.java

示例5: scheduleMimeEmail

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
private void scheduleMimeEmail(OffsetDateTime when, int priority) throws UnsupportedEncodingException, CannotSendEmailException, URISyntaxException {
    InlinePicture inlinePicture = createGalaxyInlinePicture();

    final Email email = DefaultEmail.builder()
            .from(new InternetAddress("[email protected]",
                    "Hari Seldon"))
            .to(newArrayList(
                    new InternetAddress("[email protected]",
                            "Cleon I")))
            .subject(String.format("Mime email scheduled with firetime '%s' and priority %d", when, priority))
            .body("")//this will be overridden by the template, anyway
            .attachment(getCsvForecastAttachment("forecast"))
            .encoding("UTF-8").build();

    String template = "emailTemplate.ftl";

    Map<String, Object> modelObject = ImmutableMap.of(
            "title", "Emperor",
            "name", "Cleon I"
    );

    emailSchedulerService.schedule(email, when, priority,
            template, modelObject, inlinePicture);
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:25,代码来源:TestService.java

示例6: sendMimeEmailWithPebble

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
public void sendMimeEmailWithPebble() throws UnsupportedEncodingException, CannotSendEmailException, URISyntaxException {
    InlinePicture inlinePicture = createGalaxyInlinePicture();

    final Email email = DefaultEmail.builder()
            .from(new InternetAddress("[email protected]",
                    "Hari Seldon"))
            .to(newArrayList(
                    new InternetAddress("[email protected]",
                            "Cleon I")))
            .subject("You shall die! It's not me, it's Psychohistory")
            .body("")//this will be overridden by the template, anyway
            .attachment(getCsvForecastAttachment("forecast"))
            .encoding("UTF-8").build();

    String template = "emailTemplate.html";

    Map<String, Object> modelObject = ImmutableMap.of(
            "title", "Emperor",
            "name", "Cleon I"
    );

    emailService.send(email, template, modelObject, inlinePicture);
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:24,代码来源:TestService.java

示例7: getSimpleMail

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
public static Email getSimpleMail(InternetAddress from, EmailAttachment... emailAttachments) throws UnsupportedEncodingException {
    final DefaultEmail.DefaultEmailBuilder builder = DefaultEmail.builder()
            .from(from)
            .replyTo(getCiceroSecondayMailAddress())
            .to(Lists.newArrayList(new InternetAddress("[email protected]", "[email protected]", "Pomponius Attĭcus")))
            .cc(Lists.newArrayList(new InternetAddress("[email protected]", "Titus Lucretius Carus"),
                    new InternetAddress("[email protected]", "Info Best Seller")))
            .bcc(Lists.newArrayList(new InternetAddress("[email protected]", "Caius Memmius")))
            .depositionNotificationTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .receiptTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .subject("Laelius de amicitia")
            .body("Firmamentum autem stabilitatis constantiaeque eius, quam in amicitia quaerimus, fides est.")
            .customHeaders(CUSTOM_HEADERS)
            .encoding(StandardCharsets.UTF_8.name());
    if (nonNull(emailAttachments) && emailAttachments.length > 0) {
        builder.attachments(asList(emailAttachments));
    }
    return builder.build();
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:20,代码来源:EmailToMimeMessageTest.java

示例8: shouldIgnoreNullTo

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
@Test
public void shouldIgnoreNullTo() throws Exception {
    //Arrange
    when(javaMailSender.createMimeMessage()).thenReturn(new MimeMessage((Session) null));

    final DefaultEmail email = DefaultEmail.builder()
            .from(getCiceroMainMailAddress())
            .replyTo(getCiceroSecondayMailAddress())
            .cc(Lists.newArrayList(new InternetAddress("[email protected]", "Titus Lucretius Carus"),
                    new InternetAddress("[email protected]", "Info Best Seller")))
            .bcc(Lists.newArrayList(new InternetAddress("[email protected]", "Caius Memmius")))
            .depositionNotificationTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .receiptTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .subject("Laelius de amicitia")
            .body("Firmamentum autem stabilitatis constantiaeque eius, quam in amicitia quaerimus, fides est.")
            .customHeaders(CUSTOM_HEADERS)
            .build();


    //Act
    MimeMessage message = emailToMimeMessage.apply(email);

    //Assert
    assertions.assertThat(message.getRecipients(Message.RecipientType.TO)).isNullOrEmpty();
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:26,代码来源:EmailToMimeMessageTest.java

示例9: shouldIgnoreNullCc

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
@Test
public void shouldIgnoreNullCc() throws Exception {
    //Arrange
    when(javaMailSender.createMimeMessage()).thenReturn(new MimeMessage((Session) null));

    final DefaultEmail email = DefaultEmail.builder()
            .from(getCiceroMainMailAddress())
            .replyTo(getCiceroSecondayMailAddress())
            .to(Lists.newArrayList(new InternetAddress("[email protected]", "[email protected]", "Pomponius Attĭcus")))
            .bcc(Lists.newArrayList(new InternetAddress("[email protected]", "Caius Memmius")))
            .depositionNotificationTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .receiptTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .subject("Laelius de amicitia")
            .body("Firmamentum autem stabilitatis constantiaeque eius, quam in amicitia quaerimus, fides est.")
            .customHeaders(CUSTOM_HEADERS)
            .build();


    //Act
    MimeMessage message = emailToMimeMessage.apply(email);

    //Assert
    assertions.assertThat(message.getRecipients(Message.RecipientType.CC)).isNullOrEmpty();
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:25,代码来源:EmailToMimeMessageTest.java

示例10: shouldIgnoreNullBcc

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
@Test
public void shouldIgnoreNullBcc() throws Exception {
    //Arrange
    when(javaMailSender.createMimeMessage()).thenReturn(new MimeMessage((Session) null));

    final DefaultEmail email = DefaultEmail.builder()
            .from(getCiceroMainMailAddress())
            .replyTo(getCiceroSecondayMailAddress())
            .to(Lists.newArrayList(new InternetAddress("[email protected]", "[email protected]", "Pomponius Attĭcus")))
            .cc(Lists.newArrayList(new InternetAddress("[email protected]", "Titus Lucretius Carus"),
                    new InternetAddress("[email protected]", "Info Best Seller")))
            .depositionNotificationTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .receiptTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .subject("Laelius de amicitia")
            .body("Firmamentum autem stabilitatis constantiaeque eius, quam in amicitia quaerimus, fides est.")
            .customHeaders(CUSTOM_HEADERS)
            .build();


    //Act
    MimeMessage message = emailToMimeMessage.apply(email);

    //Assert
    assertions.assertThat(message.getRecipients(Message.RecipientType.BCC)).isNullOrEmpty();
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:26,代码来源:EmailToMimeMessageTest.java

示例11: shouldIgnoreNullReceiptTo

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
@Test
public void shouldIgnoreNullReceiptTo() throws Exception {
    //Arrange
    when(javaMailSender.createMimeMessage()).thenReturn(new MimeMessage((Session) null));

    final DefaultEmail email = DefaultEmail.builder()
            .from(getCiceroMainMailAddress())
            .replyTo(getCiceroSecondayMailAddress())
            .to(Lists.newArrayList(new InternetAddress("[email protected]", "[email protected]", "Pomponius Attĭcus")))
            .cc(Lists.newArrayList(new InternetAddress("[email protected]", "Titus Lucretius Carus"),
                    new InternetAddress("[email protected]", "Info Best Seller")))
            .depositionNotificationTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .subject("Laelius de amicitia")
            .body("Firmamentum autem stabilitatis constantiaeque eius, quam in amicitia quaerimus, fides est.")
            .customHeaders(CUSTOM_HEADERS)
            .build();


    //Act
    MimeMessage message = emailToMimeMessage.apply(email);

    //Assert
    assertions.assertThat(message.getHeader("Return-Receipt-To")).isNullOrEmpty();
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:25,代码来源:EmailToMimeMessageTest.java

示例12: shouldIgnoreNullDispositionNotificationTo

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
@Test
public void shouldIgnoreNullDispositionNotificationTo() throws Exception {
    //Arrange
    when(javaMailSender.createMimeMessage()).thenReturn(new MimeMessage((Session) null));

    final DefaultEmail email = DefaultEmail.builder()
            .from(getCiceroMainMailAddress())
            .replyTo(getCiceroSecondayMailAddress())
            .to(Lists.newArrayList(new InternetAddress("[email protected]", "[email protected]", "Pomponius Attĭcus")))
            .cc(Lists.newArrayList(new InternetAddress("[email protected]", "Titus Lucretius Carus"),
                    new InternetAddress("[email protected]", "Info Best Seller")))
            .receiptTo(new InternetAddress("[email protected]", "Gaius Iulius Caesar Augustus Germanicus"))
            .subject("Laelius de amicitia")
            .body("Firmamentum autem stabilitatis constantiaeque eius, quam in amicitia quaerimus, fides est.")
            .customHeaders(CUSTOM_HEADERS)
            .build();


    //Act
    MimeMessage message = emailToMimeMessage.apply(email);

    //Assert
    assertions.assertThat(message.getHeader("Disposition-Notification-To")).isNullOrEmpty();
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:25,代码来源:EmailToMimeMessageTest.java

示例13: shouldIgnoreNullCustomHeaders

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
@Test
public void shouldIgnoreNullCustomHeaders() throws Exception {
    //Arrange
    when(javaMailSender.createMimeMessage()).thenReturn(new MimeMessage((Session) null));

    final DefaultEmail email = DefaultEmail.builder()
            .from(getCiceroMainMailAddress())
            .replyTo(getCiceroSecondayMailAddress())
            .to(Lists.newArrayList(new InternetAddress("[email protected]", "[email protected]", "Pomponius Attĭcus")))
            .cc(Lists.newArrayList(new InternetAddress("[email protected]", "Titus Lucretius Carus"),
                    new InternetAddress("[email protected]", "Info Best Seller")))
            .subject("Laelius de amicitia")
            .body("Firmamentum autem stabilitatis constantiaeque eius, quam in amicitia quaerimus, fides est.")
            .build();


    //Act
    MimeMessage message = emailToMimeMessage.apply(email);

    //Assert
    verify(emailToMimeMessage, never()).setCustomHeaders(email, message);
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:23,代码来源:EmailToMimeMessageTest.java

示例14: shouldIgnoreEmptyCustomHeaders

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
@Test
public void shouldIgnoreEmptyCustomHeaders() throws Exception {
    //Arrange
    when(javaMailSender.createMimeMessage()).thenReturn(new MimeMessage((Session) null));

    final DefaultEmail email = DefaultEmail.builder()
            .from(getCiceroMainMailAddress())
            .replyTo(getCiceroSecondayMailAddress())
            .to(Lists.newArrayList(new InternetAddress("[email protected]", "[email protected]", "Pomponius Attĭcus")))
            .cc(Lists.newArrayList(new InternetAddress("[email protected]", "Titus Lucretius Carus"),
                    new InternetAddress("[email protected]", "Info Best Seller")))
            .subject("Laelius de amicitia")
            .body("Firmamentum autem stabilitatis constantiaeque eius, quam in amicitia quaerimus, fides est.")
            .customHeaders(ImmutableMap.of())
            .build();


    //Act
    MimeMessage message = emailToMimeMessage.apply(email);

    //Assert
    verify(emailToMimeMessage, never()).setCustomHeaders(email, message);
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:24,代码来源:EmailToMimeMessageTest.java

示例15: createEmailFullContent

import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; //导入依赖的package包/类
private Email createEmailFullContent() throws Exception {
    return DefaultEmail.builder()
            .from(new InternetAddress("[email protected]"))
            .to(ImmutableList.of(new InternetAddress("[email protected]"),
                    new InternetAddress("[email protected]")))
            .cc(ImmutableList.of(new InternetAddress("[email protected]"),
                    new InternetAddress("[email protected]")))
            .bcc(ImmutableList.of(new InternetAddress("[email protected]"),
                    new InternetAddress("[email protected]"),
                    new InternetAddress("[email protected]")))
            .replyTo(new InternetAddress("[email protected]"))
            .receiptTo(new InternetAddress("[email protected]"))
            .depositionNotificationTo(new InternetAddress("[email protected]"))
            .encoding("UTF-16")
            .locale(Locale.ITALY)
            .sentAt(SEND_AT_DATE)
            .subject("subject")
            .body("body")
            .attachment(DefaultEmailAttachment.builder().attachmentName("attachment1.pdf").mediaType(MediaType.APPLICATION_PDF).attachmentData(new byte[]{}).build())
            .attachment(DefaultEmailAttachment.builder().attachmentName("attachment2.pdf").mediaType(MediaType.APPLICATION_PDF).attachmentData(new byte[]{}).build())
            .customHeaders(ImmutableMap.of("header1", "value1", "header2", "value2"))
            .build();
}
 
开发者ID:ozimov,项目名称:spring-boot-email-tools,代码行数:24,代码来源:EmailRendererConfigurationTest.java


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