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:0.0.2'
}
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@email.com");
// or
header.addTo(["email@email.com"]);
// or
header.setTos(["email@email.com"]);
String[] tos = header.getTos();
header.addSubstitution("key", "value");
JSONObject subs = header.getSubstitutions();
header.addUuniqueAarg("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();
String headers = header.jsonString();
./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.