Skip to content

Commit

Permalink
Change api for single to address
Browse files Browse the repository at this point in the history
  • Loading branch information
nschwalbe committed Apr 16, 2017
1 parent 5288272 commit 90816f4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.nschwalbe</groupId>
<artifactId>postoffice</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>

<parent>
<groupId>org.springframework.boot</groupId>
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/de/nschwalbe/postoffice/PostOffice.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -33,6 +34,38 @@ public PostOffice(MailStorage mailStorage, JavaMailSender mailSender) {
this.mailSender = mailSender;
}

/**
* Creates a mail, stores it and sends it out later. This method returns immediately and does not wait for the mail server.
*
* @param subject the mail subject.
* @param from the sender address.
* @param to the recipient.
* @param content the mail body.
* @param isHtml true if mail body is html, if it is plain text set to false.
* @return the persisted mail
* @throws MessagingException if message creation failed due to some error.
*/
public PersistedMail postMail(String subject, MailAddress from, MailAddress to, String content, boolean isHtml) throws MessagingException {
MimeMessage mimeMessage = createMimeMessage(subject, from, Collections.singletonList(to), content, isHtml);
return postMail(mimeMessage);
}

/**
* Creates a mail, stores it and sends it out later. This method returns immediately and does not wait for the mail server.
*
* @param subject the mail subject.
* @param from the sender address.
* @param to the recipient.
* @param html the mail body html part.
* @param text the mail body text part.
* @return the persisted mail.
* @throws MessagingException if message creation failed due to some error.
*/
public PersistedMail postMail(String subject, MailAddress from, MailAddress to, String html, String text) throws MessagingException {
MimeMessage mimeMessage = createMimeMessage(subject, from, Collections.singletonList(to), html, text);
return postMail(mimeMessage);
}

/**
* Creates a mail, stores it and sends it out later. This method returns immediately and does not wait for the mail server.
*
Expand Down

0 comments on commit 90816f4

Please sign in to comment.