Java

Official MailSetu Java SDK. Works with Java 11+ for email, SMS, inbound, webhooks, and Verify / OTP.

Installation (Maven)

xml
<dependency>
    <groupId>in.mailsetu</groupId>
    <artifactId>mailsetu-java</artifactId>
    <version>0.2.6</version>
</dependency>

Installation (Gradle)

groovy
implementation 'in.mailsetu:mailsetu-java:0.2.6'

Send an email

java
import in.mailsetu.MailSetu;
import java.util.List;
import java.util.Map;

MailSetu client = new MailSetu(System.getenv("MAILSETU_API_KEY"));

String response = client.emails().send(Map.of(
    "from", "Acme <noreply@acme.co>",
    "to", List.of("user@example.com"),
    "subject", "Welcome to Acme!",
    "html", "<h1>Welcome!</h1>"
));
System.out.println(response);

Start an OTP verification

java
String service = client.verify().createService(Map.of(
    "name", "Login OTP",
    "codeLength", 6,
    "ttlSeconds", 300
));

String verification = client.verify().start(Map.of(
    "serviceId", "verify_service_id",
    "to", "+919876543210",
    "idempotencyKey", "login-otp-1"
));

String check = client.verify().check("verify_id", "123456");