为电子邮件发送sendgrid

编程入门 行业动态 更新时间:2024-10-22 19:37:21
本文介绍了为电子邮件发送sendgrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用sendgrid进行电子邮件消息传递,但出现以下错误.我的代码在错误下方.

I an using sendgrid for email messaging but get the error below. My code is below the error.

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"); String subject = "Sending with SendGrid is Fun"; Email to = new Email("ayobami.o.idowu@gmail"); 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的所有可能的帖子.请帮助我我做错了什么?

I have tried every possible post on Stack Overflow. Please help me in what am I doing wrong?

推荐答案

org.apache.http.conn.ssl.AllowAllHostnameVerifier

上述类已被删除API级别22

Above class has been removed API level 22

您应该使用改为使用HttpURLConnection 类.

更多推荐

为电子邮件发送sendgrid

本文发布于:2023-11-06 06:35:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562952.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:邮件发送   电子   sendgrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!