All Projects → sendgrid → Sendgrid Java

sendgrid / Sendgrid Java

Licence: mit
The Official Twilio SendGrid Led, Community Driven Java API Library

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Sendgrid Java

Sendgrid Python
The Official Twilio SendGrid Led, Community Driven Python API Library
Stars: ✭ 1,125 (+196.05%)
Mutual labels:  transactional-emails, email, sendgrid
Sendgrid Ruby
The Official Twilio SendGrid Led, Community Driven Ruby API Library
Stars: ✭ 520 (+36.84%)
Mutual labels:  transactional-emails, email, sendgrid
Sendgrid Go
The Official Twilio SendGrid Led, Community Driven Golang API Library
Stars: ✭ 710 (+86.84%)
Mutual labels:  transactional-emails, email, sendgrid
Sendgrid Csharp
The Official Twilio SendGrid Led, Community Driven C#, .NetStandard, .NetCore API Library
Stars: ✭ 835 (+119.74%)
Mutual labels:  transactional-emails, email, sendgrid
Sendgrid Php
The Official Twilio SendGrid Led, Community Driven PHP API Library
Stars: ✭ 1,257 (+230.79%)
Mutual labels:  transactional-emails, email, sendgrid
Sendgrid Nodejs
The Official Twilio SendGrid Led, Community Driven Node.js API Library
Stars: ✭ 2,543 (+569.21%)
Mutual labels:  transactional-emails, email, sendgrid
Magento2 Gmail Smtp App
Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers
Stars: ✭ 281 (-26.05%)
Mutual labels:  transactional-emails, email, sendgrid
Mailjet Apiv3 Java
[API v3] Mailjet Java API Wrapper
Stars: ✭ 53 (-86.05%)
Mutual labels:  transactional-emails, email
Mailjet Gem
[API v3] Mailjet official Ruby GEM
Stars: ✭ 119 (-68.68%)
Mutual labels:  transactional-emails, email
Grunt Email Workflow
A Grunt workflow for designing and testing responsive HTML email templates with SCSS.
Stars: ✭ 3,010 (+692.11%)
Mutual labels:  transactional-emails, email
Mailjet Apiv3 Nodejs
[API v3] Official Mailjet API v3 NodeJS wrapper
Stars: ✭ 137 (-63.95%)
Mutual labels:  transactional-emails, email
Mailjet Apiv3 Php
[API v3] Mailjet PHP Wrapper
Stars: ✭ 194 (-48.95%)
Mutual labels:  transactional-emails, email
Cuttlefish
Transactional email server with a lovely web interface
Stars: ✭ 985 (+159.21%)
Mutual labels:  transactional-emails, email
Omnimail
Send email across all platforms using one interface
Stars: ✭ 325 (-14.47%)
Mutual labels:  email, sendgrid
nest-sendgrid
No description or website provided.
Stars: ✭ 24 (-93.68%)
Mutual labels:  email, sendgrid
Email Templates
📫 Create, preview, and send custom email templates for Node.js. Highly configurable and supports automatic inline CSS, stylesheets, embedded images and fonts, and much more!
Stars: ✭ 3,291 (+766.05%)
Mutual labels:  email, sendgrid
Laravel Postmark
A Postmark adapter for Laravel
Stars: ✭ 143 (-62.37%)
Mutual labels:  transactional-emails, email
Fluentemail
All in one email sender for .NET. Supports popular senders (SendGrid, MailGun, etc) and Razor templates.
Stars: ✭ 1,888 (+396.84%)
Mutual labels:  email, sendgrid
Mailer
A light-weight, modular, message representation and mail delivery framework for Python.
Stars: ✭ 225 (-40.79%)
Mutual labels:  email, sendgrid
content-reminder
⏰ A GitHub Action that reminds you to share your own content
Stars: ✭ 28 (-92.63%)
Mutual labels:  email, sendgrid

SendGrid Logo

Travis Badge Maven Central Email Notifications Badge Twitter Follow GitHub contributors Open Source Helpers MIT licensed

NEW: Subscribe to email notifications for releases and breaking changes.

The default branch name for this repository has been changed to main as of 4.7.2.

This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via Java.

Version 3.X.X of this library provides full support for all Twilio SendGrid Web API v3 endpoints, including the new v3 /mail/send.

This library represents the beginning of a new path for Twilio SendGrid. We want this library to be community driven and Twilio SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create issues and pull requests or simply upvote or comment on existing issues or pull requests.

Please browse the rest of this README for further details.

We appreciate your continued support, thank you!

Table of Contents

Installation

Prerequisites

  • Java 8 or 11
  • The Twilio SendGrid service, starting at the free level to send up to 4.7.2 emails for the first 30 days, then send 100 emails/day free forever or check out our pricing.

Setup Environment Variables

Update the development environment with your SENDGRID_API_KEY, for example:

  1. Copy the sample environment file to a new file
cp .env_sample .env
  1. Edit the new .env to add your API key
  2. Source the .env file to set the variable in the current session
source .env

Install Package

Choose your installation method - Maven w/ Gradle (recommended), Maven or Jar file.

via Maven w/ Gradle

Add the following to your build.gradle file in the root of your project.

...
dependencies {
  ...
  implementation 'com.sendgrid:sendgrid-java:4.7.2'
}

repositories {
  mavenCentral()
}
...

via Maven

mvn install

via jar file

You can just drop the jar file in. It's a fat jar - it has all the dependencies built in.

sendgrid-java.jar

Dependencies

Quick Start

Hello Email

The following is the minimum needed code to send an email with the /mail/send Helper (here is a full example):

With Mail Helper Class

import com.sendgrid.*;
import java.io.IOException;

public class Example {
  public static void main(String[] args) throws IOException {
    Email from = new Email("[email protected]");
    String subject = "Sending with Twilio SendGrid is Fun";
    Email to = new Email("[email protected]");
    Content content = new Content("text/plain", "and easy to do anywhere, even with Java");
    Mail mail = new Mail(from, subject, to, content);

    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    try {
      request.setMethod(Method.POST);
      request.setEndpoint("mail/send");
      request.setBody(mail.build());
      Response response = sg.api(request);
      System.out.println(response.getStatusCode());
      System.out.println(response.getBody());
      System.out.println(response.getHeaders());
    } catch (IOException ex) {
      throw ex;
    }
  }
}

The Mail constructor creates a personalization object for you. Here is an example of how to add to it.

Without Mail Helper Class

The following is the minimum needed code to send an email without the /mail/send Helper (here is a full example):

import com.sendgrid.*;
import java.io.IOException;

public class Example {
  public static void main(String[] args) throws IOException {
    try {
      SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
      Request request = new Request();
      request.setMethod(Method.POST);
      request.setEndpoint("mail/send");
      request.setBody("{\"personalizations\":[{\"to\":[{\"email\":\"[email protected]\"}],\"subject\":\"Sending with Twilio SendGrid is Fun\"}],\"from\":{\"email\":\"[email protected]\"},\"content\":[{\"type\":\"text/plain\",\"value\": \"and easy to do anywhere, even with Java\"}]}");
      Response response = sg.api(request);
      System.out.println(response.getStatusCode());
      System.out.println(response.getBody());
      System.out.println(response.getHeaders());
    } catch (IOException ex) {
      throw ex;
    }
  }
}

General v3 Web API Usage

import com.sendgrid.*;
import java.io.IOException;

public class Example {
  public static void main(String[] args) throws IOException {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    try {
      Request request = new Request();
      request.setMethod(Method.GET);
      request.setEndpoint("api_keys");
      Response response = sg.api(request);
      System.out.println(response.getStatusCode());
      System.out.println(response.getBody());
      System.out.println(response.getHeaders());
    } catch (IOException ex) {
      throw ex;
    }
  }
}

Usage

Use Cases

Examples of common API use cases, such as how to send an email with a transactional template.

Announcements

Please see our announcement regarding breaking changes. Your support is appreciated!

All updates to this library are documented in our CHANGELOG and releases. You may also subscribe to email release notifications for releases and breaking changes.

How to Contribute

We encourage contribution to our libraries (you might even score some nifty swag), please see our CONTRIBUTING guide for details.

Quick links:

Troubleshooting

Please see our troubleshooting guide for common library issues.

About

sendgrid-java is maintained and funded by Twilio SendGrid, Inc. The names and logos for sendgrid-java are trademarks of Twilio SendGrid, Inc.

If you need help installing or using the library, please check the Twilio SendGrid Support Help Center.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

License

The MIT License (MIT)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].