SendGrid SMTP API Java Bindings
This module lets you build SendGrid's SMTP API headers with simplicity.
Requirements
Java 1.6 and later.
Installation
Maven
Add this dependency to your project's POM:
<dependency>
<groupId>com.revinate</groupId>
<artifactId>sendgrid-smtpapi-java</artifactId>
<version>2.0.0</version>
</dependency>
Gradle
Add this dependency to your project's build script:
compile 'com.revinate:sendgrid-smtpapi-java:2.0.0'
Usage
Create header
import com.revinate.sendgrid.smtpapi.*;
SmtpApi header = new SmtpApiImpl();
Get header value
String headerValue = header.toSmtpApiHeader();
If you need the unescaped JSON string:
String rawHeaderValue = header.toRawSmtpApiHeader();
To
header.addSmtpApiTo("[email protected]");
// or
header.addSmtpApiTo("[email protected]", "Email User");
List<String> tos = header.getSmtpApiTos();
Substitutions
header.addValueToSubstitution("key", "value");
List<String> substitution = header.getSubstitution("key");
Unique Arguments
header.setUniqueArg("key", "value");
String arg = header.getUniqueArg("key");
Categories
header.addCategory("category");
List<String> categories = header.getCategories();
Sections
header.setSection("key", "section");
String section = header.getSection("key");
Filters
header.setSettingInFilter("filter", "setting", "value");
header.setSettingInFilter("filter", "setting", 1);
Map<String, Object> filter = header.getFilter("filter");
ASM Group ID
header.setAsmGroupId(1);
Integer groupId = header.getAsmGroupId();
Scheduling
header.setSendAt(1416427645);
Integer sendAt = header.getSendAt();
IP Pool
header.setIpPool("transactional");
String ipPool = header.getIpPool();
License
Licensed under the MIT License.