This module will let you build SendGrid's SMTP API headers with simplicity.
Choose your installation method - Maven w/ Gradle (recommended) or Jar file.
...
dependencies {
...
compile 'com.sendgrid:smtpapi-java:1.2.0'
}
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.
import com.sendgrid.smtpapi.SMTPAPI;
SMTPAPI header = new SMTPAPI();
header.addTo("[email protected]");
// or
header.addTo(["[email protected]"]);
// or
header.setTos(["[email protected]"]);
String[] tos = header.getTos();
header.addSubstitution("key", "value");
JSONObject subs = header.getSubstitutions();
header.addUniqueAarg("key", "value");
// or
Map map = new HashMap<String, String>();
map.put("unique", "value");
header.setUniqueArgs(map);
// or
JSONObject map = new JSONObject();
map.put("unique", "value");
header.setUniqueArgs(map);
JSONObject args = header.getUniqueArgs();
header.addCategory("category");
// or
header.addCategory(["categories"]);
// or
header.setCategories(["category1", "category2"]);
String[] cats = header.getCategories();
header.addSection("key", "section");
// or
Map newSec = new HashMap();
newSec.put("-section-", "value");
header.setSections(newSec);
// or
JSONObject newSec = new JSONObject();
newSec.put("-section-", "value");
header.setSections(newSec);
JSONObject sections = header.getSections();
header.addFilter("filter", "setting", "value");
header.addFilter("filter", "setting", 1);
JSONObject filters = header.getFilters();
header.setASMGroupId(1);
Integer groupId = header.getASMGroupId();
header.setSendAt(1416427645)
int sendAt = header.getSendAt();
String headers = header.jsonString();
If you need the unescaped JSON string.
String rawJson = header.rawJsonString();
./gradlew check
This only works if you have the correct permissions - for admins only basically.
cp gradle.properties.example gradle.properties
Edit the contents of gradle.properties with your credentials.
./gradlew
./gradlew uploadArchives
Login to Sonatype.
Go to staging repositories page.
Click 'Close' with the archive selected.
Wait a few minutes, and refresh the staging repositories page.
Check the box for the SendGrid repo again and this time click 'Release'.
You're all done.