Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
SendGrid Web API
Search
ktsuda
September 15, 2016
800
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SendGrid Web API
難しいメール送信を手軽に
ktsuda
September 15, 2016
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Google's AI Overviews - The New Search
badams
0
1.6k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
560
Abbi's Birthday
coloredviolet
4
10k
エンジニアに許された特別な時間の終わり
watany
109
250k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Building Adaptive Systems
keathley
44
3.2k
Why Our Code Smells
bkeepers
PRO
340
58k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
540
Transcript
SendGrid Web API ͍͠ϝʔϧૹ৴Λखܰʹ
͓ » ϝʔϧۀ » SMTP / Web API » ·ͱΊ
ϝʔϧ ϝʔϧͷૹ৴ྉ ૿Ճ͠ଓ͚͍ͯΔɻ ʢ݄ؒ 270ԯ௨ʣ
ϝʔϧͷछྨ » Transactional Mail » ձһొɺωοτ௨ൢɺύεϫʔυมߋ » Marketing Mail »
Ӧۀɾސ٬ಈɾᅂੳ
ϝʔϧͷࣄେม » Πϯϑϥઃܭɾߏங » ʹ߹Θͤͯεέʔϧ (ෆಈ࢈Խ) » อक » ιϑτΣΞΠϯετʔϧ
» ࢹج൫ » ηΩϡϦςΟ » ۓٸোରԠ
ϝʔϧͷࣄେม » ϑΟʔυόοΫϧʔϓͷγεςϜԽ » ໎ϝʔϧ / εύϜτϥοϓճආ » ղใͷऩू »
Open / ClickτϥοΩϯά
ϝʔϧͷࣄେม » ISPͷBlocklist » ೝূ » SPF: ૹ৴ݩIPΞυϨεΛ֬ೝɻ » DKIM:
ిࢠॺ໊Λ༩͠ૹ৴ݩ͕ਖ਼͔ݕূɻ » DMARC: SPF/ DKIM྆ํʹࣦഊͨ͠߹ͷϧʔϧɻ
None
ϝʔϧͷࣄେม » Ϛʔέολͷχʔζ » ϩάղੳج൫ » υϦϧμϯ༻γεςϜߏங
ϝʔϧͷࣄେม » ίετ͕അࣛʹͳΒͳ͍ » ސ٬ͱͷՍ͚ڮ ͱͯେࣄ ͱͯେม
SendGrid » ΫϥυϕʔεͷSMTPαʔϏε » ղܾ͢Δͷ… » ΤϯδχΞͷۤ » Ϛʔέολͷۤ »
ड৴ऀͷۤ » ͦͷ݁Ռ… Ϗδωεʹूத // ΑΓॏཁͳ࣮ʹूத
SMTPαʔϏεʁ » ಥ͖٧ΊΕ… ϝʔϧΛಧ͚Δ͜ͱʢૹΔ͡Όͳͯ͘ʣ » ϝʔϧΛಧ͚Δ… ਖ਼͘͠ɺૉૣ͘ɺͨ͘͞Μ » Ͳ͏ͬͯ… SMTP
X-SMTPAPI
SMTP Transport $ telnet smtp.sendgrid.net 587 $ openssl s_client -connect
smtp.sendgrid.net:465 » High Latency αʔόͱͷΓऔΓ͕ଟ͍
SMTP Transport 220 SG ESMTP service ready at ismtpd0017p1sin1.sendgrid.net 250-smtp.sendgrid.net
250-8BITMIME 250-PIPELINING 250-SIZE 31457280 250-STARTTLS 250-AUTH PLAIN LOGIN 250 AUTH=PLAIN LOGIN 334 VXNlcm5hbWU6 334 UGFzc3dvcmQ6 235 Authentication successful 250 Sender address accepted 250 Recipient address accepted 354 Continue 250 Ok: queued as sS0HQxlITZWHC4Q4BrLInw 221 See you later
Web Transport POST /api/mail.send.json HOST: api.sendgrid.com
[email protected]
&
[email protected]
X-SMTPAPI ֦ுϔομ: X-SMTPAPI: { ... } { "user": "************", "pass":
"************", "tos": [ "
[email protected]
", "
[email protected]
", "
[email protected]
", ... "
[email protected]
" ] }
ൺֱ X-SMTPAPIͰɺѼઌ͝ͱʹίωΫγϣϯΛΔΑΓेߴͰ͢ ͕ɻ » 100௨ͷϝʔϧΛX-SMTPAPIͰૹ৴ » ϩʔΧϧͰͷૹ৴։͔࢝Βɺ100௨ͷૹ৴ॲཧ͕ྃ͢Δ·Ͱ
SMTP require 'mail' require 'smtpapi' # sendgrid/smtpapi-ruby smtapi = Smtpapi::Header.new
... mail = Mail.new(charste: UTF-8) do ... end mail['X-SMTPAPI'] = smtpapi.to_json mail.delivery_method(:smtp, address: 'smtp.sendgrid.net', port: 587, domain: 'gmail.com', authentication: :login, user_name: sendgrid_username, password: sendgrid_password) Ѽઌ100݅Ͱ7ඵ
Web API v2 curl -X POST https://api.sendgrid.com/api/mail.send.json \ -H "Authorization:
Bearer ${SENDGRID_API_KEY}" \ -d
[email protected]
\ -d
[email protected]
\ -d subject="Hello Word" \ -d text="This is a test email. Delete me whenever you like." \ -d headers='{"X-SMTPAPI":"{\"to\":[\"
[email protected]
\",...]}"}' Ѽઌ100݅Ͱ4ඵ
ൺֱ » SMTP: 7ඵ (SMTP 1ίωΫγϣϯ/ SMTPAPI) » Web API
v2: 4ඵ
ൺֱ » SMTPͷσϑΥϧτϙʔτ » SMTPΦʔόʔϔου͕େ͖͍ » SMTPͷઃఆ໘͍͘͞ » Web API࣮͕؆୯
» ։ൃऀʹ͍͞͠ Web APIܦ༝ͰɺαΫοͱϝʔϧૹ৴͠·͠ΐ͏
Libraries » sendgrid/sendgrid-nodejs » sendgrid/sendgrid-php » sendgrid/sendgrid-python » sendgrid/sendgrid-go »
sendgrid/sendgrid-ruby » sendgrid/sendgrid-csharp » sendgrid/sendgrid-cobol » sendgrid/sendgrid-perl
API » ϚʔέςΟϯά » Ѽઌཧ » ೝূઃఆ » ૹ৴ (΄΅)ͯ͢ͷػೳΛAPIܦ༝Ͱ
Web API v3 ग़·ͨ͠! ͞Βʹૉૣ࣮͘ curl -X POST https://api.sendgrid.com/v3/mail/send \
-H "Authorization: Bearer ${SENDGRID_API_KEY}" \ -H "Content-Type: application/json" \ -d @data.json ͪ͜ΒɺѼઌ100݅Ͱ4ඵ
data.json { "personalizations": [ { "to": [ { "email": "
[email protected]
"
}, ... ], "subject": "Hello, World" } ], "from": { "email": "
[email protected]
" }, ...
... "content": [ { "type": "text/plain", "value": "This is a
test email. Delete me whenever you like." } ] } JSONͷόϦσʔτ ৄͪ͘͜͠Βɻ https://sendgrid.com/docs/APIReference/WebAPI_v3/Mail/ index.html
ศརػೳ » Event Webhook ൃੜͨ͠ΠϕϯτใΛࢦఆͨ͠URLʹPOST ྫ) ϩάղੳج൫ » Inbound Parse
Webhook ड৴ͨ͠ϝʔϧΛࢦఆͨ͠URLʹPOST ྫ) ࣗࣾΞϓϦέʔγϣϯͰϝʔϧΛड৴ ྫ) ϝʔϧΛτϦΨʔʹ
͋Γ͕ͱ͏͍͟͝·ͨ͠ » υΩϡϝϯτ&νϡʔτϦΞϧ: https://sendgrid.kke.co.jp/docs/ » ެࣜϥΠϒϥϦ: https://github.com/sendgrid/ » KKE sample
codes: https://github.com/sendgridjp/ Happy Sending!