Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SendGrid Web API
Search
ktsuda
September 15, 2016
780
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
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.4k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
RailsConf 2023
tenderlove
30
1.5k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
190
The Art of Programming - Codeland 2020
erikaheidi
57
14k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
410
A Tale of Four Properties
chriscoyier
163
24k
The SEO Collaboration Effect
kristinabergwall1
1
480
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
160
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!