If you have a non-library SendGrid issue, please contact our support team.
If you can't find a solution below, please open an issue.
- Migrating from v2 to v3
- Continue Using v2
- Testing v3 /mail/send Calls Directly
- Versions
- Environment Variables and Your SendGrid API Key
- Using the Package Manager
- Android Compatibility
- Viewing the Request Body
Please review our guide on how to migrate from v2 to v3.
Here is the last working version with v2 support.
Add the following to your build.gradle file in the root of your project.
...
dependencies {
...
compile 'com.sendgrid:sendgrid-java:2.2.2'
}
repositories {
mavenCentral()
}
...
You can just drop the jar file in. It's a fat jar - it has all the dependencies built in.
Here are some cURL examples for common use cases.
We follow the MAJOR.MINOR.PATCH versioning scheme as described by SemVer.org. Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guaranteed to be a breaking change. Changes are documented in the CHANGELOG and releases section.
All of our examples assume you are using environment variables to hold your SendGrid API key.
If you choose to add your SendGrid API key directly (not recommended):
System.getenv("SENDGRID_API_KEY")
becomes
"SENDGRID_API_KEY"
In the first case SENDGRID_API_KEY is in reference to the name of the environment variable, while the second case references the actual SendGrid API Key.
We upload this library to Maven whenever we make a release. This allows you to use maven and gradle for easy installation.
In most cases we recommend you download the latest version of the library, but if you need a different version, please use:
...
dependencies {
...
compile 'com.sendgrid:sendgrid-java:X.X.X'
}
repositories {
mavenCentral()
}
...
Since Android SDK 23, HttpClient is no longer supported. Some workarounds can be found here.
We have an issue to remove that dependency here, please upvote to move it up the queue.
When debugging or testing, it may be useful to examine the raw request body to compare against the documented format.
You can do this right before you call request.setBody(mail.build())
like so:
System.out.println(mail.build());