We recommend using SendGrid Java, our client library, available on Github, with full documentation.

Using SendGrid’s Java Library

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// using SendGrid's Java Library - https://github.com/sendgrid/sendgrid-java
import com.sendgrid.*;

public class SendGridExample {
  public static void main(String[] args) {
    SendGrid sendgrid = new SendGrid(api_user, api_key);

    SendGrid.Email email = new SendGrid.Email();

    email.addTo("test@sendgrid.com");
    email.setFrom("you@youremail.com");
    email.setSubject("Sending with SendGrid is Fun");
    email.setHtml("and easy to do anywhere, even with Java");

    SendGrid.Response response = sendgrid.send(email);
  }
}