This repo features the Brand new Java wrapper for the Mailjet API. Check out the Offical Documentation
Add the following in your pom.xml
<dependencies>
<dependency>
<groupId>com.mailjet</groupId>
<artifactId>mailjet-client</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
Grab your keys here
MailjetClient client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
Requests are easy to understand
MailjetRequest request = MailjetRequest(resource, id, actionId)
MailjetRequest contacts;
MailjetResponse response;
contacts = new MailjetRequest(Contact.resource);
response = client.get(contacts);
MailjetRequest contacts;
MailjetResponse response;
contacts = new MailjetRequest(Contact.resource)
.filter(Contact.LIMIT, 2);
response = client.get(contacts);
MailjetRequest contacts;
MailjetResponse response;
contacts = new MailjetRequest(Contact.resource, id);
response = client.get(contacts);
MailjetRequest contacts;
MailjetResponse response;
sender = new MailjetRequest(Sender.resource)
.property(Sender.EMAIL, "[email protected]");
response = client.post(sender);
MailjetRequest email;
JSONArray recipients;
MailjetResponse response;
recipients = new JSONArray()
.put(new JSONObject().put(Contact.EMAIL, "[email protected]"))
.put(new JSONObject().put(Contact.EMAIL, "[email protected]"))
.put(new JSONObject().put(Contact.EMAIL, "[email protected]"));
email = new MailjetRequest(Email.resource)
.property(Email.FROMNAME, "Guillaume")
.property(Email.FROMEMAIL, "[email protected]")
.property(Email.SUBJECT, "Subject")
.property(Email.TEXTPART, "Java is coming!...")
.property(Email.RECIPIENTS, recipients)
.property(Email.MJCUSTOMID, "JAVA-Email");
response = client.post(email);
MailjetRequest getSender = new MailjetRequest(Sender.resource)
.filter(Sender.EMAIL, "email adress");
MailjetResponse senders = client.get(getSender);
// Grab the first sender
JSONObject sender = senders.getData().getJSONObject(0);
// Change the name
MailjetRequest update = new MailjetRequest(Sender.resource, sender.getLong("ID"))
.setBody(sender.put(Sender.NAME, "new name"));
System.out.println(client.put(update));
- head