Skip to content

Latest commit

 

History

History
67 lines (50 loc) · 1.86 KB

README.md

File metadata and controls

67 lines (50 loc) · 1.86 KB

Resend Java SDK

License: MIT Build Release

Installation

To install the Java SDK, add the following dependency to your project:

Gradle

implementation 'com.resend:resend-java:3.0.2'

Maven

<dependency>
    <groupId>com.resend</groupId>
    <artifactId>resend-java</artifactId>
    <version>3.0.2</version>
</dependency>

Setup

First, you need to get an API key, which is available in the Resend Dashboard.

Example

package com.resend;

import com.resend.services.emails.model.*;
import com.resend.core.provider.AuthenticationProvider;
import com.resend.core.provider.impl.AuthenticationProviderStandard;
import com.resend.services.emails.ResendEmails;

public class Main {
    public static void main(String[] args) {
        Resend resend = new Resend("re_123");

        CreateEmailOptions params = CreateEmailOptions.builder()
                .from("Me <me@exemple.io>")
                .to("to@example", "you@example.com")
                .cc("carbon@example.com", "copy@example.com")
                .bcc("blind@example.com", "carbon.copy@example.com")
                .replyTo("reply@example.com", "to@example.com")
                .text("Hello, world!")
                .subject("Hello from Java!")
                .build();

        try {
            CreateEmailResponse data = resend.emails().send(params);
            System.out.println(data.getId());
        } catch (ResendException e) {
            e.printStackTrace();
        }
    }
}

You can view all the examples in the examples folder