This module allows you to build SendGrid's SMTP API headers with simplicity.
All updates to this module are documented in our CHANGELOG.
- Java 8, 11, or 17
- The SendGrid service, starting at the free level
Choose your installation method - Maven w/ Gradle (recommended) or Jar file.
... dependencies { ... compile 'com.sendgrid:smtpapi-java:1.3.3' } repositories { mavenCentral() } ...
Then import the library - in the file appropriate to your Java project.
import com.sendgrid.smtpapi.SMTPAPI;
You can just drop the jar file in. It's a fat jar - it has all the dependencies built in.
Update the development environment with your SENDGRID_API_KEY, for example:
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env echo "sendgrid.env" >> .gitignore source ./sendgrid.env
- See pom.xml.
import com.sendgrid.smtpapi.SMTPAPI; public class Example { public static void main(String[] args) { SMTPAPI header = new SMTPAPI(); header.addTo("test@example.com"); String headers = header.jsonString(); System.out.println(headers); } }
We encourage contribution to our projects, please see our CONTRIBUTING guide for details.
Quick links:
smtpapi-java is maintained and funded by Twilio SendGrid, Inc. The names and logos for smtpapi-java are trademarks of Twilio SendGrid, Inc.
If you need help using SendGrid, please check the Twilio SendGrid Support Help Center.