Hi George, thanks for the reply!

My project is a spring MVC project. I'm using a trial version of Sendgrid. I 
haven't updated my billing details(could this be a reason for failure).
Here's the relevant code snippet :

Method 1:
public static boolean sendEmail(String emailId) {

    Sendgrid mail = new Sendgrid("my_username","my_password"); //Input: 
SendGrid username, password
    mail.setTo(emailId) //to ID
        .setFrom("my_email...@gmail.com") //from ID
        .setSubject("Sending first mail with Sendgrid") //subject
        .setText("thanks for subscribing!"); //content
                
        try {
                mail.send();
            }
        catch (JSONException e) {
            logger.info("JSON exception occured");
            return false;
         }
            return true;
}

Method 2: I've tried the version that uses Api key too:
 
        Email from = new Email("my_emai...@gmail.com");
        String subject = "Sending first mail with Sendgrid";
        Email to = new Email(emailId);
        Content content = new Content("text/plain", "thanks for subscribing!");
        Mail mail = new Mail(from, subject, to, content);
        
        SendGrid sg = new SendGrid(SENDGRID_API_KEY);
        Request request = new Request();
        request.setMethod(Method.POST);
        request.setEndpoint("mail/send");
        request.setBody(mail.build());
        Response response = sg.api(request);
        
        if(response.getStatusCode()!=200) {
                logger.info("response status is ", response.getStatusCode());
                return false;
        }


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/708a33a1-44b1-4d39-bcb5-3b17aba13b0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to