åç´ã«ãAPI Key ãåå¾ã㦠curl ã§éãã ããã¨ããã®ããã£ã¦ã¿ã¾ãããªããSendGrid ã¸ã®ã¢ã«ã¦ã³ãã®ç»é²ã¯æ¸ãã§ãããã®ã¨ãã¾ãã
æé ã®æ¦è¦
- API Key ãçæï¼åå¾ï¼ãã
- API Key ãå«ãã ãPOST ç¨ ã® JSON ãã¡ã¤ã«ãä½æãã
- ä¸è¨ã® JSON ã POST ãã
å ·ä½çæé
1. API Key ãçæï¼åå¾ï¼ãã
è¨å®ç»é¢å ã® API Key ã®ãã¼ã¸ã«è¡ã£ã¦ API Key ãçæãã¾ãã以ä¸ã®ãã«ããã¼ã¸ã«å¾ãã°ããã§ãã
2. API Key ãå«ãã ãPOST ç¨ ã® JSON ãã¡ã¤ã«ãä½æãã
ãã¨ãã°ã以ä¸ã®ãã㪠JSON ãã¡ã¤ã«ãä½ãã¾ãããã¡ã¤ã«åã¯ãmy_sendgrid.js
ã¨ã§ããã¾ãã
{ "personalizations": [ { "to": [ { "email": "éãå ã®äººã®åå@hogehoge.com" } ], "subject": "ããã«ã¡ã¯ï¼" } ], "from": { "email": "ãããã®åå@foobar.com" }, "content": [ { "type": "text/plain", "value": "ããã¹ãã¡ã¼ã«ã§ãï¼" } ] }
3. ä¸è¨ã® JSON ã curl 㧠POST ãã
ä¸è¨ã§ä½æãã my_sendgrid.js
ã curl 㧠POST ãã¾ããcurl 㧠-d ãªãã·ã§ã³ãç¨ããéã«ãã®å¯¾è±¡ããã¡ã¤ã«ã®å ´åã¯ãå
é ã«ã¢ãããã¼ã¯ @
ãã¤ããã°ããã§ãã
$ curl -X POST https://api.sendgrid.com/v3/mail/send -d @my_sendgrid.js -H "Authorization: Bearer ããã«åå¾ããAPI Keyãå ¥ã" -H "Content-Type: application/json"
4. å®è¡çµæã¨ãã¦ä½ãè¿ã£ã¦ããªããã° OK
curl ãå®è¡ãã¦ä½äºããªãã³ãã³ããçµäºããã°éä¿¡ã§ãã¦ããã¯ãã§ããéä¿¡ããã¦ãããã©ããã確èªãã¾ãããã
è£è¶³
ä»åã®å 容ã¯æä½éã®åºæ¬çãªä½¿ãæ¹ãæ¸ãããã®ã§ãã®ã§ããã«ããããã¥ã¡ã³ããèªã¿è¾¼ãã§ãã便å©ã«ä½¿ãããªãã¾ããããè¨èªå¥ã®ã©ã¤ãã©ãªãããã±ã¼ã¸ãç¨ããã°ãããç°¡æ½æçã«æ¸ããã¨æãã¾ãã