To use, send
a PostmarkMessage
with an instance of PostmarkClient
.
First, create a PostmarkClient
with your Server Token:
PostmarkClient postmark = new PostmarkClient("YOUR_SERVER_TOKEN");
Or with a "defaul from address" (see the javadocs for PostmarkClient
for more info):
PostmarkClient postmark = new PostmarkClient("YOUR_SERVER_TOKEN", new PostmarkAddress("email@example.com"));
Or with a "default from address" with a "name":
PostmarkClient postmark = new PostmarkClient("YOUR_SERVER_TOKEN", new PostmarkAddress("My Company", "email@example.com"));
See the other PostmarkClient
constructors for more options.
Then create a PostmarkMessage
:
PostmarkMessage message = new PostmarkMessage("Example Subject", new PostmarkAddress("User Name", "user@example.org"));
message.setTextBody("This is an exmaple message.");
See the set*
and add*
methods on PostmarkMessage
for more options.
Then send the message:
postmark.send(message); // catch exceptions as needed
That's it! Check out the javadocs for more info.
I hate projects with a ton of dependencies, but the reality is that better tools can be built faster when "standing on the shoulders of giants", so here we go.
For very clean JSON serialization/deserialization. It's the XStream of JSON (because JSON with XStream is an extremely cludgy hack).
For making HTTP/HTTPS requests. URLConnection just doesn't cut it.
HttpClient 4 also depends on:
- Commons Logging (or jcl-over-slf4j, because commons-logging is for wimps)
- Commons Codec (also required by postmark4j)
- httpcore (included)
- httpmime (included)
For logging, obviously. Built with slf4j-simple, but you'll use your own binding.
Used for parsing ISO 8601 dates. This thing is over 500k, so I'd love to avoid it, but parsing ISO 8601 date/time strings ends up being non-trivial otherwise. If you don't like it, ask Wildbit to return date/times in a more Java-friendly format (SimpleDateFormat can't parse the ISO 8601 timezone format).
HttpClient needs it, so we use it too.
Because we're lazy.
- Unit tests for serialization/deserialization
- Refactoring to allow subclasses of
PostmarkClient
to provide a customHttpClient
implementation.
- Remove incorrect CRLF chunking from attachment data.
- Attachments (pretty basic, doesn't verify type or size yet).
- Batch message sending
- JodaTime for proper parsing of ISO 8601 date/time
- Better docs
- Package reorganization
- Renamed to postmark4j
- Hard-code message entity as UTF-8 in PostmarkClient