-
Notifications
You must be signed in to change notification settings - Fork 21
Email sending
Igor Balos edited this page Nov 9, 2017
·
24 revisions
With Postmark you can send email super easy. Before diving into this chapter, make sure you have checked out our getting started page.
To send a simple email, all you need is to create a mail message object, retrieve Postmark API client and send the message. You can validate the message by validating result of MessageResponse class.
String htmlBody = "<!DOCTYPE html><html><body>" +
"<p>Hello<a href=\"http://www.google.com\">world</a></p></body></html>";
// create a simple email message
Message message = new Message("[email protected]", "[email protected]", "Hello from Postmark!", htmlBody);
message.setReplyTo("[email protected]");
// Deliver a simple message
ApiClient client = Postmark.getApiClient(<server token>);
MessageResponse response = client.deliverMessage(message);
System.out.println(response.getMessage());
Message message = new Message("[email protected]", "[email protected]", "Hello Postmark! with tag", "Hello body");
message.setTag("testTag");
client.deliverMessage(message);
String htmlBody = "<!DOCTYPE html><html><body>" +
"<p>Hello<a href=\"http://www.google.com\">world</a></p></body></html>";
Message message = new Message("[email protected]", "[email protected]", "Hello Postmark!", htmlBody);
message.setTrackOpens(true);
client.deliverMessage(message);
Message message = new Message("[email protected]", "[email protected]", "Hello Postmark!", htmlBody);
// set tracking type, it can be Message.TRACK_LINKS.Html, Message.TRACK_LINKS.Html or Message.TRACK_LINKS.HtmlAndText
message.setTrackLinks(Message.TRACK_LINKS.HtmlAndText);
client.deliverMessage(message);
For additional information about the capabilities of the Postmark API, see Postmark Developers Documentation.