sendgrid-javaThere’s a new addition to the family of SendGrid libraries. Java developers can now use sendgrid-java, a module for sending emails through SendGrid using Java.

You’ve always been able to send emails through SendGrid using Java. You could use one of Java’s built in SMTP libraries to communicate with our SMTP API or you could use an http request library to communicate with our Web API.

However, you had to write a fair amount of boilerplate code for both of these approaches. I recently had to build a Java application using SendGrid, and I was discouraged with this boilerplate code.

As I coded the application, I started pulling pieces out into a file. This evolved into the SendGrid Java library you see today.

How to use it

To begin, add the library to your Java application. I recommend using gradle for this (detailed instructions here), but you can simply add the file to your project if you prefer.

Then where you need, initiate the SendGrid object with your SendGrid credentials.

import com.github.sendgrid.SendGrid;
SendGrid sendgrid = new SendGrid("sendgrid_username", "sendgrid_password");

Add your message details.

sendgrid.addToName("Example Guy");
sendgrid.setSubject("Hello World");
sendgrid.setText("My first email through SendGrid");

And finally, send it.


Enjoy! As of writing, the library is at version 0.1.0 and is stable. If you run into any bugs file them on the issues page.

Hacker in LA. I believe the future is bright. It's up to us to build it - as programmers we get a big say. Follow me on twitter @motdotla.