2017-10-01 15 views
1

파스텔 클라우드 코드와 함께 SendGrid 템플릿을 사용할 수 있습니까?파스 클라우드 - 템플릿이있는 Sendgrid

이 작동하지만 텍스트 만 보내면 template_id 사용 방법에 대한 아이디어가 있습니까?

필터로 시도했지만 성공하지 못했습니다. 누구나 간단 밝혀졌다 답을 찾는 경우

Parse.Cloud.define("sendEmail", function(request, response) { 

    // Import SendGrid module and call with your SendGrid API Key 
    var sg = require('sendgrid')('your SendGrid API key here'); 

    // Create the SendGrid Request 
    var reqSG = sg.emptyRequest({ 
    method: 'POST', 
    path: '/v3/mail/send', 
    body: { 
     personalizations: [ 
     { 
      to: [ 
      { 
       // This field is the "to" in the email 
       email: request.params.toEmail, 
      }, 
      ], 
      // This field is the "subject" in the email 
      subject: request.params.subject, 
     }, 
     ], 
     // This field contains the "from" information 
     from: { 
     email: '[email protected]', 
     name: 'Your Name', 
     }, 
     // This contains info about the "reply-to" 
     // Note that the "reply-to" may be different than the "from" 
     reply_to: { 
     email: '[email protected]', 
     name: 'Your Name', 
     }, 
     content: [ 
     { 
      type: 'text/plain', 
      value: request.params.body, 
     }, 
     ], 
    }, 
    }); 

    sg.API(reqSG, function(SGerror, SGresponse) { 
    // Testing if some error occurred 
    if (SGerror) { 
     // Ops, something went wrong 
     console.error('Error response received'); 
     console.error('StatusCode=' + SGresponse.statusCode); 
     console.error(JSON.stringify(SGresponse.body)); 
     response.error('Error = ' + JSON.stringify(SGresponse.body)); 
    } 
    else { 
     // Everything went fine 
     console.log('Email sent!'); 
     response.success('Email sent!'); 
    } 
    }); 

}); 

가 텍스트를 입력 메시지를 개인화로 template_id을 추가 및 변경,

답변