SendGrid不使用文档中的API示例发送电子邮件

问题描述 投票:1回答:1

我使用的文档与示例相同:

public static void main(String[] args) throws Exception {

    Email from = new Email("****@gmail.com");
    String subject = "Sending with SendGrid is Fun";
    Email to = new Email("****@gmail.com");
    Content content = new Content("text/plain", "and easy to do anywhere, even with Java");
    Mail mail = new Mail(from, subject, to, content);
    SendGrid sg = new SendGrid("API KEY");

    Request request = new Request();
    try {
        request.setMethod(Method.POST);
        request.setEndpoint("mail/send");
        request.setBody(mail.build());
        Response response = sg.api(request);
        System.out.println("response.getStatusCode() ------------------- "+response.getStatusCode());
        System.out.println("response.getBody() -------- "+response.getBody());
        System.out.println("response.getHeaders() -------- "+response.getHeaders());
    } catch (IOException ex) {
        throw ex;
    }
}

我什至可以看到响应代码为response.getStatusCode() ------------------- 202

但是我仍然没有收到任何电子邮件。还需要在sendgrid端进行任何其他配置吗?

java sendgrid sendgrid-api-v3
1个回答
0
投票

我正在收到邮件。

© www.soinside.com 2019 - 2024. All rights reserved.