Postmark Java API
Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
src
.gitignore
README.md
build.xml
pom.xml

README.md

README

This library allows you to leverage the Postmark REST API to send emails.

Installation

Maven

    <groupId>com.jaredholdcroft.java</groupId>
    <artifactId>postmark-java</artifactId>
    <version>1.2</version>

Usage

List<NameValuePair> headers = new ArrayList<NameValuePair>();

headers.add(new NameValuePair("HEADER", "test"));

PostmarkMessage message = new PostmarkMessage("FROM_ADDRESS",
        "TO_ADDRESS",
        "REPLY_TO_ADDRESS",
        null,
        "SUBJECT",
        "CONTENT",
        false,
        null,
        headers);

PostmarkClient client = new PostmarkClient("POSTMARK_API_TEST");

try {
       client.sendMessage(message);
} catch (PostmarkException pe) {
       System.out.println("An error has occured : " + pe.getMessage());
}

Attachments can also be sent:

Attachment attachment = new Attachment();
attachment.setContentType("application/pdf");
attachment.setName("SomethingAwesome.pdf");

// convert file contents to base64
File file = new File("SomethingAwesome.pdf");
byte[] ba = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
Fileis.read(ba);
fis.close();
attachment.setContent(new Base64().encodeToString(ba));

// can handle multiple attachments
Vector<Attachment> v = new Vector<Attachment>();
v.add(attachment);
message.setAttachments(v);

Dependencies:

All dependencies are included in the lib folder