當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。