Skip to content

jkaninda/posta-java

Repository files navigation

Posta Java Client

A lightweight Java client for the Posta email API.

Requirements

  • Java 11+
  • Jackson Databind

Installation

Maven

Add the JitPack repository to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Then add the dependency:

<dependency>
    <groupId>com.github.jkaninda</groupId>
    <artifactId>posta-java</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.jkaninda:posta-java:1.0.0'
}

Usage

import com.github.jkaninda.posta.*;

PostaClient client = new PostaClient("https://posta.example.com", "your-api-key");

Send Email

SendResponse response = client.sendEmail(new SendEmailRequest()
    .from("sender@example.com")
    .to(List.of("recipient@example.com"))
    .subject("Hello")
    .html("<h1>Hello World</h1>"));
// response.getId(), response.getStatus()

Send Template Email

SendResponse response = client.sendTemplateEmail(new SendTemplateEmailRequest()
    .template("welcome")
    .to(List.of("user@example.com"))
    .templateData(Map.of("name", "John")));

Send Batch Emails

BatchResponse response = client.sendBatch(new BatchRequest()
    .template("newsletter")
    .recipients(List.of(
        new BatchRecipient().email("alice@example.com").templateData(Map.of("name", "Alice")),
        new BatchRecipient().email("bob@example.com").templateData(Map.of("name", "Bob"))
    )));
// response.getTotal(), response.getSent(), response.getFailed()

Get Email Status

EmailStatusResponse status = client.getEmailStatus("email-uuid");
// status.getStatus(), status.getRetryCount()

Error Handling

try {
    client.sendEmail(request);
} catch (PostaException e) {
    System.out.println(e.getStatusCode()); // HTTP status code
    System.out.println(e.getMessage());    // Error message
}

Contributing

Contributions are welcome! Please open an issue to discuss proposed changes before submitting a pull request.

License

This project is licensed under the MIT License. See LICENSE for details.


Made with ❤️ for the developer community

Star us on GitHub — it motivates us to keep improving!

Copyright © 2026 Jonas Kaninda

About

Posta Java Client

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages