簡體   English   中英

SendGrid 在 Google 應用引擎端點中不起作用

[英]SendGrid not working in Google app engine endpoints

我需要將信息發送到谷歌端點,然后使用 Sendgrid 設置對象,然后發送電子郵件。 電子郵件不起作用,應用程序引擎沒有發送任何內容。

我的端點代碼的一部分:

@ApiMethod(name = "sendEmail")
public sendEmailObject sendEmail(@Named("sendTo") String sendTo, @Named("sentFromClient") String sentFromClient, @Named("sendDescription") String sendDescription) {

    SendGrid sendgrid = new SendGrid(..., ...);
    SendGrid.Email email = new SendGrid.Email();
    email.addTo(..);
    email.addToName(..);
    email.setReplyTo(..);
    email.setSubject(..);
    email.setText(..);
    email.setFrom(...);

    sendEmailObject emailoObject = new sendEmailObject();
    try {
        SendGrid.Response response = sendgrid.send(email);
        emailoObject.setSendMailSucccess(response.getMessage().toString());
    } catch (SendGridException e) {
        e.printStackTrace();
        emailoObject.setSendMailSucccess(e.toString());
    }

我需要在應用引擎上設置什么嗎? 像打開端口或其他一些設置? Sendgrid 似乎使用端口 5252,但不知道在哪里允許該端口,或者是否自動完成? 我在注冊 Sendgrid 時也使用了不同的電子郵件,而不是 App 引擎,這會導致問題嗎?

問題是在創建 Sendgrid 對象時我使用了用戶名和密碼。 當我將其更改為在 sendgrid 上生成的密鑰時,它起作用了!!!

 SendGrid sendgrid = new SendGrid("key");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM