implementation 'com.resend.api:sdk:1.5.3'
<dependency>
<groupId>com.resend.api</groupId>
<artifactId>sdk</artifactId>
<version>1.5.3</version>
</dependency>
To authenticate you need to add an Authorization header with the contents of the header being Bearer re_123456789 where re_123456789 is your API Key. First, you need to get an API key, which is available in the Resend Dashboard.
Authorization: Bearer re_123
package hello.world;
import com.resend.sdk.Resend;
import com.resend.sdk.models.shared.Security;
import com.resend.sdk.models.operations.SendEmailRequest;
import com.resend.sdk.models.operations.SendEmailResponse;
import com.resend.sdk.models.shared.Email;
public class Application {
public static void main(String[] args) {
try {
Resend.Builder builder = Resend.builder();
builder.setSecurity(
new Security() {{
bearerAuth = "Bearer YOUR_BEARER_TOKEN_HERE";
}}
);
Resend sdk = builder.build();
SendEmailRequest req = new SendEmailRequest() {{
request = new Email() {{
bcc = "[email protected]";
cc = "";
from = "[email protected]";
html = "none";
replyTo = "";
subject = "hello world";
text = "first email";
to = "[email protected]";
}};
}};
SendEmailResponse res = sdk.email.sendEmail(req);
if (res.sendEmailResponse.isPresent()) {
// handle response
}
} catch (Exception e) {
// handle exception
}
sendEmail
- Send an email
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release !