【问题标题】:issues sendgrid for email messaging为电子邮件发送问题 sendgrid
【发布时间】:2018-09-13 17:39:26
【问题描述】:

我使用 sendgrid 发送电子邮件,但收到以下错误。我的代码低于错误。

Error:  Caused by: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar:classes3.dex)
                          at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
                          at  

电子邮件消息代码:

Email from = new Email("zihronProjectManagementApp@gmail.com");

    String subject = "Sending with SendGrid is Fun";

    Email to = new Email("ayobami.o.idowu@gmail.com");

    Content content = new Content("text/plain", "and easy to do anywhere, even with Java");

    Mail mail = new Mail(from, subject, to, content);

    //Toast.makeText(getApplicationContext(),System.getenv('"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"),Toast.LENGTH_LONG).show();

    SendGrid sg = new SendGrid(System.getenv("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"));

    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());

        System.out.println(response.getBody());

        System.out.println(response.getHeaders());

    } catch (IOException ex) {


    }

我已经尝试了 Stack Overflow 上所有可能的帖子。请帮我解决我做错了什么?

【问题讨论】:

    标签: java android android-studio sendgrid sendgrid-api-v3


    【解决方案1】:
    org.apache.http.conn.ssl.AllowAllHostnameVerifier
    

    API 级别 22 已删除以上类

    您应该改用HttpURLConnection 类。

    【讨论】:

    • 你知道如何在android gradle中实现HttpURLConnection类吗?
    • @XingTimisencoGenesis 我不知道您的问题是否已经解决,或者您是否还需要解决方案。但实际上有人将 Sendgrid 插件修改为使用 HttpURLConnection。看这里的插件:github.com/danysantiago/sendgrid-android
    猜你喜欢
    • 2018-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-30
    • 2017-12-26
    • 1970-01-01
    相关资源
    最近更新 更多