Subversion Repositories SmartDukaan

Rev

Rev 20537 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
20531 kshitij.so 1
package com.hotspotstore.services;
2
 
3
import com.sendgrid.*;
4
import java.io.IOException;
5
 
6
public class SendGridMail {
7
 
8
	private static String API_KEY ="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";
9
 
20561 kshitij.so 10
	public static void sendMail(String mailTo, String subject, String body) throws IOException {
20531 kshitij.so 11
		Email from = new Email("help@saholic.com");
20561 kshitij.so 12
		Email to = new Email(mailTo);
13
		Content content = new Content("text/plain", body);
20531 kshitij.so 14
		Mail mail = new Mail(from, subject, to, content);
15
 
20537 kshitij.so 16
		SendGrid sg = new SendGrid(API_KEY);
20531 kshitij.so 17
		Request request = new Request();
18
		try {
19
			request.method = Method.POST;
20
			request.endpoint = "mail/send";
21
			request.body = mail.build();
22
			Response response = sg.api(request);
23
			System.out.println(response.statusCode);
24
			System.out.println(response.body);
25
			System.out.println(response.headers);
26
		} catch (IOException ex) {
27
			throw ex;
28
		}
29
	}
30
}