2015-11-05 132 views
0

我得到一个内部服务器异常获取邮件信息,同时使用lutung的Java API的mandrill。这是我的代码。如何获取Mandrill java api发送的邮件状态?

public MandrillMessageInfo getMessageInfo(String id) { 
MandrillApi mandrillApi = new MandrillApi("Your api key"); 
MandrillMessageInfo info = null; 
try { 
    info = mandrillApi.messages().info(id); 
    log.debug("Message status-> Email {}, state: {}, timeOfSent: {} ", info.getEmail() ,info.getState(), TimeUtil.getLocalTimeString(info.getTs())); 
} catch (Exception e) { 
    log.debug("Exception occurs while getting message info for id: {}, exception is: {} ", id, e.getMessage()); 
    throw new MailServiceException(ErrorCodes.ERROR_INTERNAL_SERVER_ERROR, ErrorCodes.ERROR_MESSAGE_INTERNAL_SERVER_ERROR); 
} 
return info; 
} 
+0

它看起来像你自己抛出内部服务器异常? – Xiao

+0

是的。但** info()**方法,我已经调用抛出** MandrillApiError **异常。我的问题是,我如何获得有关发送邮件的信息? –

回答

1

我在代码中看不到任何错误。如果你的API密钥是正确的,这个请求将返回一个错误的唯一原因是如果你给一个错误的ID。您可以通过使用“Try It”按钮https://mandrillapp.com/api/docs/messages.JSON.html#method=info直接在mandrill网站上发送消息/ info api请求来验证该消息,并传递您通过程序调用给出的相同消息ID。

希望这会有所帮助,

+0

谢谢。 API密钥正确,但不幸的是消息ID错误。 –

相关问题