1// using SendGrid's Java Library
2// https://github.com/sendgrid/sendgrid-java
4import com.sendgrid.helpers.mail.*;
5import com.sendgrid.helpers.mail.objects.*;
6import java.io.IOException;
9public static void main(String[] args) throws IOException {
10Email from = new Email("test@example.com");
11String subject = "Sending with SendGrid is Fun";
12Email to = new Email("test@example.com");
13Content content = new Content("text/plain", "and easy to do anywhere, even with Java");
14Mail mail = new Mail(from, subject, to, content);
16SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
17Request request = new Request();
19request.setMethod(Method.POST);
20request.setEndpoint("mail/send");
21request.setBody(mail.build());
22Response response = sg.api(request);
23System.out.println(response.getStatusCode());
24System.out.println(response.getBody());
25System.out.println(response.getHeaders());
26} catch (IOException ex) {
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4