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
510
商品監視を支える技術.key.pdf
ichikawa
0
87
SendGridで人生変わった
ichikawa
2
2.2k
Other Decks in Programming
See All in Programming
Full stack testing :: basic to basic
up1
1
930
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
210
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.6k
Recoilを剥がしている話
kirik
5
6.6k
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
210
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
190
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Designing Experiences People Love
moore
138
23k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
We Have a Design System, Now What?
morganepeng
51
7.3k
What's in a price? How to price your products and services
michaelherold
243
12k
The Pragmatic Product Professional
lauravandoore
32
6.3k
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 Ͱࣗͷύοέʔδ͕ೖΔͷخ͍͠ɻ ͬͯΒ͑Δͱࣗ৴ʹͳΔɻ
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠