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
Laravel with SendGrid
Search
s-ichikawa
June 16, 2016
Programming
0
2.8k
Laravel with SendGrid
Laravel勉強会 2016/6/17 発表資料
s-ichikawa
June 16, 2016
Tweet
Share
More Decks by s-ichikawa
See All by s-ichikawa
15分で分かった気になるGraphQL
ichikawa
3
3.1k
GraphQL入門
ichikawa
3
1.1k
ReactPHPとの戯れ
ichikawa
0
490
商品監視を支える技術.key.pdf
ichikawa
0
86
SendGridで人生変わった
ichikawa
2
2.2k
Other Decks in Programming
See All in Programming
Go言語でターミナルフレンドリーなAIコマンド、afaを作った/fukuokago20_afa
monochromegane
2
140
WEBエンジニア向けAI活用入門
sutetotanuki
0
300
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
110
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
130
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
220
開発効率向上のためのリファクタリングの一歩目の選択肢 ~コード分割~ / JJUG CCC 2024 Fall
ryounasso
0
360
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
150
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
16
4k
カスタムしながら理解するGraphQL Connection
yanagii
1
1.2k
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
5
3.3k
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
160
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
810
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
39
2.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
32
1.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
Rails Girls Zürich Keynote
gr2m
93
13k
Designing Experiences People Love
moore
138
23k
Making Projects Easy
brettharned
115
5.9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
Transcript
Laravel with SendGrid 2016.5.17
I am … Twitter: @ichikawa_0829 ▸ ϑϦʔϥϯε ▸ dots.
What is SendGrid?
What is SendGrid ▸ ϝʔϧ৴Λߦ͏ͨΊͷΫϥυαʔϏε ▸ ΞΧϯτൃߦ͢Ε͙͢ʹSMTPଓɺWeb(REST) APIɺϚʔέ ςΟϯάϝʔϧػೳΛͬͯϝʔϧΛૹ৴Ͱ͖Δ ▸
ແྉ͕͋Δ(ແྉͰ400௨/) ▸ SMTP APIͱ͍͏ػೳ͕ศར ▸ ։෧ΫϦοΫͷΠϕϯτΛHookͰ͖Δ ▸ ཧը໘͔Β༷ʑͳ౷ܭใ͕ࢀরՄೳ About
None
None
In Laravel
LaravelͰϝʔϧΛૹ৴͢Δ߹ ▸ SendGridͷSMTPαʔόΛ͏ ▸ WebAPIΛ͏ In Laravel
SendGridͷSMTPαʔόΛ͏ ▸ ެࣜHP ͰLaravelͰૹ৴͢Δํ๏ͱͯ͠ɺ͜ͷํ๏͕հ ͞Ε͍ͯ·͢ ▸ config/mail.phpʹSendGridͷSMTPαʔόͷଓใΛ ࢦఆ͢Δ͚ͩɻ ▸ ؆୯ʂ
In Laravel
<?php return array( 'driver' => 'smtp', 'host' => 'smtp.sendgrid.net', 'port'
=> 587, 'from' => array('address' => '
[email protected]
', 'name' => 'John Smith'), 'encryption' => 'tls', 'username' => 'sendgrid_username', 'password' => 'sendgrid_password', ); config/mail.php In Laravel SendGridͷSMTPαʔόΛ͏
Web APIΛͬͯϝʔϧΛૹ৴͢Δ߹ ▸ SendGridͷ΄΅શͯͷػೳWebAPIܦ༝Ͱ༻͢ΔͨΊ ͷΤϯυϙΠϯτ͕༻ҙ͞Ε͍ͯΔ ▸ curlެࣜϥΠϒϥϦɺίϛϡχςΟϕʔεϥΠϒϥϦΛ ༻ͯ͠ϦΫΤετ͛Δ ▸ SendGridͷSMTPαʔόΛ͏ΑΓॲཧ͕ૣ͘ऴΔέʔε͕
ଟ͍ͷͰՄೳͳΒWeb APIΛ͏͜ͱ͕ਪ͞Ε͍ͯΔ In Laravel
ૣ͘ͳΔՄೳੑ͕͋ΔͳΒWebAPI͍͍ͨ (͔͠Կނ͔֎ʹ͔ͬͯSMTPଓग़དྷͳ͍͠…)
ެࣜϥΠϒϥϦΛͬͯΈΔ ▸ sendgrid/sendgrid-php ΛcomposerͳͲͰΠϯετʔϧ͢ Δ ▸ $sendgrid = new SendGrid('YOUR_SENDGRID_APIKEY');
▸ $email = new SendGrid\Email(); ▸ $email->addTo('
[email protected]
'); // ͱ͔৭ʑઃఆ͢Δ ▸ $sendgrid->send($email); In Laravel
͏ͪΐͬͱLaravelͬΆ͘Γ͍ͨͳ͊…
͏ͪΐͬͱLaravelͬΆ͘Γ͍ͨͳ͊… (ͩͬͯMail::send()Ͱॻ͍ͯ͋Δطଘίʔυ͕ࢁɻɻɻ)
ଞΛ୳ͯ͠ݟͨΒͳ͍ɻɻɻ
࡞ͬͪΌ͓ʂ
ϝʔϧपΓͲ͏ͳͬͯΔʁ ▸ mail.driverͷઃఆʹ߹ΘͤͨTransportΫϥεΛ࣋ͭ SwiftMailerΛ$app['swift.mailer']ʹొ ▸ $app['swift.mailer']Λ࣋ͭIlluminate\Mail\Mailerͱ͍͏Ϋϥ εʹ৭ʑઃఆΛߦ͍$app['mailer']ʹొ ▸ Illuminate\Support\Facades\MailͰ$app['mailer']Λొ ࡞ͬͪΌ͓ʂ
ҙ֎ͱ࡞ΕΔ͔ ▸ ཁSendGrid༻ͷTransportΫϥε࡞ΕOK (࣮ࡍͦΕΛ ొ͢ΔҝͷTransportManagerͱɺMailServiceProvider ඞཁ) ▸ MandrillMailgunͷιʔεݟͨΒGuzzleHttp\ClientͰ POSTͯ͠Δ͚ͩ ▸
ΠέΔʂΠέΔͧʂ ࡞ͬͪΌ͓ʂ
laravel-sendgrid-deriver https://packagist.org/packages/s-ichikawa/laravel-sendgrid-driver
laravel-sendgrid-driver ▸ ଞͷdriverͱಉ༷ɺconfigϑΝΠϧʹز͔ͭઃఆΛՃ͢Ε OK ▸ SendGridΛศརʹ͏ͨΊʹ͔ܽͤͳ͍SMTP API͑Δ Α͏ʹ͠·ͨ͠ ▸ MailServiceProviderTransportManagerݩͷͷΛܧঝ
ͯ͠ΔͷͰଞͷdriverͦͷ··͑Δ ࡞ͬͪΌ͓ʂ
࡞ͬͪΌ͓ʂ 3/1 ॳPull Request 5/17 500install 5/25 1000install 5/13 N.Yͷਓ͔Β࣭
6/13 2000install
·ͱΊ ▸ ύοέʔδ։ൃLaravelͷ͍͍ษڧʹͳΓ·ͨ͠ ▸ SendGridศརɻLaravelͰ͏ͳΒlaravel-sendgrid-driver ࢼ͍͚ͯͨͩ͠Δͱخ͍͠Ͱ͢ɻ(Կ͔͋Ε༏͘͠PRΛ…) ▸ ެ։ͨ͠ʹ͍ͭͯͷ࣭PullRequestͬͺΓӳޠ͕ ଟ͍ɻӳޠ͕ΜΖ͏… ▸
composer require Ͱࣗͷύοέʔδ͕ೖΔͷخ͍͠ɻ ͬͯΒ͑Δͱࣗ৴ʹͳΔɻ
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠