2015-11-05 127 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錯誤。 –

相關問題