Skip to content

eug-filippov-mn/postmark-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Postmark Java API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%