GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - resend/resend-java: Resend's Java SDK

BranchesTags
Open more actions menu

Latest commit

 

History

162 Commits
162 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
gradle/wrapper
gradle/wrapper
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 

Repository files navigation

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:+'

Maven

<dependency>
    <groupId>com.resend</groupId>
    <artifactId>resend-java</artifactId>
    <version>LATEST</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 <[email protected]>")
                .to("to@example", "[email protected]")
                .cc("[email protected]", "[email protected]")
                .bcc("[email protected]", "[email protected]")
                .replyTo("[email protected]", "[email protected]")
                .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();
        }
    }
}

Configuration

new Resend("re_123") uses sensible defaults. Use Resend.builder() to set a proxy, timeouts or a custom base URL:

import com.resend.Resend;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.time.Duration;

// 1. Configure the proxy server
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("your.proxy.host", 8080));

// 2. Add the proxy and any other options to the builder, then build the client
Resend resend = Resend.builder()
    .apiKey("re_123")
    .proxy(proxy)
    .connectTimeout(Duration.ofSeconds(5))
    .readTimeout(Duration.ofSeconds(30))
    .build();

Create one Resend instance and reuse it: every service it returns shares the same HTTP client.

Custom HTTP client

To take full control of the HTTP layer, pass your own IHttpClient with .httpClient(...). For example, to use your own OkHttpClient (interceptors, TLS settings, a shared connection pool), add the com.squareup.okhttp3:okhttp-jvm dependency to your build and wrap it in the built-in HttpClient:

import com.resend.Resend;
import com.resend.core.net.impl.HttpClient;
import okhttp3.OkHttpClient;

// 1. Configure your OkHttpClient, e.g. with an interceptor that logs every request
OkHttpClient okHttpClient = new OkHttpClient.Builder()
    .addInterceptor(chain -> {
        System.out.println(chain.request().method() + " " + chain.request().url());
        return chain.proceed(chain.request());
    })
    .build();

// 2. Wrap it in the built-in HttpClient and build the client
Resend resend = Resend.builder()
    .apiKey("re_123")
    .httpClient(new HttpClient(okHttpClient, "https://api.resend.com"))
    .build();

A custom httpClient can't be combined with baseUrl, the timeouts or proxy; configure those on your client.

You can view all the examples in the examples folder

About

Resend's Java SDK

Resources

Readme
MIT license
Activity
Custom properties

Stars

44 stars

Watchers

2 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.