Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailvoidr Spring Boot SDK

Official Spring Boot starter for the Mailvoidr transactional email API.

Use this when SMTP port 587 is unavailable — the HTTP API delivers the same way.

Install

After the first Maven Central release:

<dependency>
    <groupId>com.mailvoidr</groupId>
    <artifactId>mailvoidr-spring-boot-starter</artifactId>
    <version>0.1.0</version>
</dependency>

Until then, build locally:

cd sdks/springboot
mvn install

Configure

MAILVOIDR_API_KEY=mvdr_live_your_key_here
MAILVOIDR_FROM_ADDRESS=hello@mail.yourdomain.com
MAILVOIDR_FROM_NAME=Acme

Or in application.yml:

mailvoidr:
  api-key: mvdr_live_your_key_here
  from-address: hello@mail.yourdomain.com
  from-name: Acme

Send mail

import com.mailvoidr.springboot.MailvoidrClient;
import com.mailvoidr.springboot.model.SendEmailRequest;
import org.springframework.stereotype.Service;

@Service
public class WelcomeService {
    private final MailvoidrClient mailvoidr;

    public WelcomeService(MailvoidrClient mailvoidr) {
        this.mailvoidr = mailvoidr;
    }

    public void sendWelcome(String to) {
        var response = mailvoidr.send(SendEmailRequest.builder()
                .to(List.of(to))
                .subject("Welcome to Acme")
                .html("<h1>Hey there</h1>")
                .trackOpens(true)
                .trackClicks(true)
                .build());

        mailvoidr.getSend(response.id());
    }
}

Send with a template

mailvoidr.send(SendEmailRequest.builder()
        .to(List.of("user@example.com"))
        .templateId("01HXYZ...")
        .variables(Map.of("name", "Riya"))
        .build());

Migrating from SendGrid

If your service already builds SendGrid v3 payloads, convert them before sending:

import com.mailvoidr.springboot.adapter.SendGridEmailAdapter;

SendEmailRequest request = SendGridEmailAdapter.toSendEmailRequest(sendGridPayload);
mailvoidr.send(request);

Errors

MailvoidrException includes the HTTP status and validation errors map for 402, 403, 422, and other API failures.

Development

mvn verify

See PUBLISHING.md for Maven Central release steps.

About

Official Spring Boot SDK for the Mailvoidr transactional email API

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages