Java SDK
The official com.camelmailer:camelmailer-java library has a fluent builder API, one runtime dependency (Jackson databind), and HTTP via the JDK’s java.net.http. Java 17+.
Install
Maven:
pom.xml
<dependency> <groupId>com.camelmailer</groupId> <artifactId>camelmailer-java</artifactId> <version>0.1.0</version> </dependency>
Gradle:
build.gradle.kts
implementation("com.camelmailer:camelmailer-java:0.1.0")Quickstart
Quickstart.java
import com.camelmailer.CamelMailer;
import com.camelmailer.emails.SendEmailRequest;
import com.camelmailer.emails.SendResult;
CamelMailer client = new CamelMailer("cm_xxxx");
SendResult result = client.emails().send(
SendEmailRequest.builder()
.from("billing@acme.com")
.to("ada@example.com")
.subject("Your receipt")
.htmlBody("<p>Thanks for your purchase.</p>")
.build());Send with a template
Template.java
client.emails().sendWithTemplate(
SendEmailRequest.builder()
.from("hello@acme.com")
.to("ada@example.com")
.template("welcome")
.templateModel(Map.of("name", "Ada"))
.build());Error handling
API failures throw the unchecked CamelMailerException, carrying the stable error code and HTTP status (0 for connection errors).
Errors.java
try {
client.emails().send(request);
} catch (CamelMailerException e) {
e.getCode(); // "ValidationError", "Unauthorized", "NotFound", ...
e.getStatusCode(); // 422, 401, 404, ... (0 for connection errors)
e.getMessage(); // human-readable detail
}Self-hosted instances
Use the builder to point at your own instance instead of the cloud:
SelfHosted.java
CamelMailer client = CamelMailer.builder()
.apiKey("cm_xxxx")
.baseUrl("https://mail.example.com")
.build();Full field reference: Messages API.
