SparkPost发送邮件异常

时间:2016-06-30 12:04:43

标签: android sparkpost

Sparkpost发送邮件 - 我已经把火花邮件的jar文件和跟星盘开发者提供的相同,但是无法发送电子邮件。

    final String API_KEY = "xxxx"; 
    sparky.sendMessage("xyz@abc.com",  // from email
    "xxx@gmail.com",                   // to email
    "The subject of the message",      // subject of email
    "The text part of the email",      // text of email body
    "<b>The HTML part of the email</b>"); // Html text of email body


But getting this exception

    com.sparkpost.exception.SparkPostErrorServerResponseException: Unexpected server response ContentType(null) from https://api.sparkpost.com/api/v1/URI [scheme=null, userInfo=null, host=null, port=-1, path=transmissions, queryParams=[num_rcpt_errors=0], fragment=null] contentLength(0)
        at com.sparkpost.transport.RestConnection.receiveErrorResponse(RestConnection.java:326)
        at com.sparkpost.transport.RestConnection.receiveResponse(RestConnection.java:235)
        at com.sparkpost.transport.RestConnection.doHttpMethod(RestConnection.java:390)
        at com.sparkpost.transport.RestConnection.post(RestConnection.java:433)
        at com.sparkpost.resources.ResourceTransmissions.createTransmission(ResourceTransmissions.java:40)
        at com.sparkpost.resources.ResourceTransmissions.create(ResourceTransmissions.java:27)
        at com.sparkpost.Client.sendMessage(Client.java:115)
        at com.sparkpost.Client.sendMessage(Client.java:90)
        at mail.SendMail$1.run(SendMail.java:60)
        at java.lang.Thread.run(Thread.java:745)

1 个答案:

答案 0 :(得分:0)

尽管使用了jar,但请尝试使用maven或gradle依赖项。当我从jcenter存储库使用gradle时,解决了我的问题。