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("[email protected]") //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("[email protected]");
        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 [email protected].
To post to this group, send email to [email protected].
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/dd9c1821-022e-428b-993f-91276ad12f9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to