Rev 20537 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.hotspotstore.services;import com.sendgrid.*;import java.io.IOException;public class SendGridMail {private static String API_KEY ="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";public static void sendMail(String mailTo, String subject, String body) throws IOException {Email from = new Email("help@saholic.com");Email to = new Email(mailTo);Content content = new Content("text/plain", body);Mail mail = new Mail(from, subject, to, content);SendGrid sg = new SendGrid(API_KEY);Request request = new Request();try {request.method = Method.POST;request.endpoint = "mail/send";request.body = mail.build();Response response = sg.api(request);System.out.println(response.statusCode);System.out.println(response.body);System.out.println(response.headers);} catch (IOException ex) {throw ex;}}}