Slide 1

Slide 1 text

Laravel with SendGrid 2016.5.17

Slide 2

Slide 2 text

I am … Twitter: @ichikawa_0829 ▸ ϑϦʔϥϯε ▸ dots.

Slide 3

Slide 3 text

What is SendGrid?

Slide 4

Slide 4 text

What is SendGrid ▸ ϝʔϧ഑৴Λߦ͏ͨΊͷΫϥ΢υαʔϏε ▸ ΞΧ΢ϯτൃߦ͢Ε͹͙͢ʹSMTP઀ଓɺWeb(REST) APIɺϚʔέ ςΟϯάϝʔϧػೳΛ࢖ͬͯϝʔϧΛૹ৴Ͱ͖Δ ▸ ແྉ࿮͕͋Δ(ແྉͰ400௨/೔) ▸ SMTP APIͱ͍͏ػೳ͕ศར ▸ ։෧΍ΫϦοΫͷΠϕϯτΛHookͰ͖Δ ▸ ؅ཧը໘͔Β༷ʑͳ౷ܭ৘ใ͕ࢀরՄೳ About

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

In Laravel

Slide 8

Slide 8 text

LaravelͰϝʔϧΛૹ৴͢Δ৔߹ ▸ SendGridͷSMTPαʔόΛ࢖͏ ▸ WebAPIΛ࢖͏ In Laravel

Slide 9

Slide 9 text

SendGridͷSMTPαʔόΛ࢖͏ ▸ ެࣜHP Ͱ͸LaravelͰૹ৴͢Δํ๏ͱͯ͠ɺ͜ͷํ๏͕঺հ ͞Ε͍ͯ·͢ ▸ config/mail.phpʹSendGridͷSMTPαʔό΁ͷ઀ଓ৘ใΛ ࢦఆ͢Δ͚ͩɻ ▸ ؆୯ʂ In Laravel

Slide 10

Slide 10 text

'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αʔόΛ࢖͏

Slide 11

Slide 11 text

Web APIΛ࢖ͬͯϝʔϧΛૹ৴͢Δ৔߹ ▸ SendGridͷ΄΅શͯͷػೳ͸WebAPIܦ༝Ͱ࢖༻͢ΔͨΊ ͷΤϯυϙΠϯτ͕༻ҙ͞Ε͍ͯΔ ▸ curl΍ެࣜϥΠϒϥϦɺίϛϡχςΟϕʔεϥΠϒϥϦΛ࢖ ༻ͯ͠ϦΫΤετ౤͛Δ ▸ SendGridͷSMTPαʔόΛ࢖͏ΑΓॲཧ͕ૣ͘ऴΔέʔε͕ ଟ͍ͷͰՄೳͳΒ͹Web APIΛ࢖͏͜ͱ͕ਪ঑͞Ε͍ͯΔ In Laravel

Slide 12

Slide 12 text

ૣ͘ͳΔՄೳੑ͕͋ΔͳΒWebAPI࢖͍͍ͨ (͔͠΋Կނ͔֎ʹ޲͔ͬͯSMTP઀ଓग़དྷͳ͍͠…)

Slide 13

Slide 13 text

ެࣜϥΠϒϥϦΛ࢖ͬͯΈΔ ▸ sendgrid/sendgrid-php ΛcomposerͳͲͰΠϯετʔϧ͢ Δ ▸ $sendgrid = new SendGrid('YOUR_SENDGRID_APIKEY'); ▸ $email = new SendGrid\Email(); ▸ $email->addTo('[email protected]'); // ͱ͔৭ʑઃఆ͢Δ ▸ $sendgrid->send($email); In Laravel

Slide 14

Slide 14 text

΋͏ͪΐͬͱLaravelͬΆ͘΍Γ͍ͨͳ͊…

Slide 15

Slide 15 text

΋͏ͪΐͬͱLaravelͬΆ͘΍Γ͍ͨͳ͊… (ͩͬͯMail::send()Ͱॻ͍ͯ͋Δطଘίʔυ͕୔ࢁɻɻɻ)

Slide 16

Slide 16 text

ଞΛ୳ͯ͠΋ݟ౰ͨΒͳ͍ɻɻɻ

Slide 17

Slide 17 text

࡞ͬͪΌ͓ʂ

Slide 18

Slide 18 text

ϝʔϧपΓͲ͏ͳͬͯΔʁ ▸ mail.driverͷઃఆʹ߹ΘͤͨTransportΫϥεΛ࣋ͭ SwiftMailerΛ$app['swift.mailer']ʹొ࿥ ▸ $app['swift.mailer']Λ࣋ͭIlluminate\Mail\Mailerͱ͍͏Ϋϥ εʹ৭ʑઃఆΛߦ͍$app['mailer']ʹొ࿥ ▸ Illuminate\Support\Facades\MailͰ$app['mailer']Λొ࿥ ࡞ͬͪΌ͓ʂ

Slide 19

Slide 19 text

ҙ֎ͱ࡞ΕΔ͔΋ ▸ ཁ͸SendGrid༻ͷTransportΫϥε࡞Ε͹OK (࣮ࡍ͸ͦΕΛ ొ࿥͢ΔҝͷTransportManagerͱɺMailServiceProvider΋ ඞཁ) ▸ Mandrill΍MailgunͷιʔεݟͨΒGuzzleHttp\ClientͰ POSTͯ͠Δ͚ͩ ▸ ΠέΔʂΠέΔͧʂ ࡞ͬͪΌ͓ʂ

Slide 20

Slide 20 text

laravel-sendgrid-deriver https://packagist.org/packages/s-ichikawa/laravel-sendgrid-driver

Slide 21

Slide 21 text

laravel-sendgrid-driver ▸ ଞͷdriverͱಉ༷ɺconfigϑΝΠϧʹز͔ͭઃఆΛ௥Ճ͢Ε ͹OK ▸ SendGridΛศརʹ࢖͏ͨΊʹ͔ܽͤͳ͍SMTP API΋࢖͑Δ Α͏ʹ͠·ͨ͠ ▸ MailServiceProvider΍TransportManager͸ݩͷ΋ͷΛܧঝ ͯ͠ΔͷͰଞͷdriver΋ͦͷ··࢖͑Δ ࡞ͬͪΌ͓ʂ

Slide 22

Slide 22 text

࡞ͬͪΌ͓ʂ 3/1 ॳPull Request 5/17 500install 5/25 1000install 5/13 N.Yͷਓ͔Β࣭໰ 6/13 2000install

Slide 23

Slide 23 text

·ͱΊ ▸ ύοέʔδ։ൃ͸Laravelͷ͍͍ษڧʹͳΓ·ͨ͠ ▸ SendGridศརɻLaravelͰ࢖͏ͳΒlaravel-sendgrid-driver ࢼ͍͚ͯͨͩ͠Δͱخ͍͠Ͱ͢ɻ(Կ͔͋Ε͹༏͘͠PRΛ…) ▸ ެ։ͨ͠෺ʹ͍ͭͯͷ࣭໰΍PullRequest͸΍ͬͺΓӳޠ͕ ଟ͍ɻӳޠ͕Μ͹Ζ͏… ▸ composer require Ͱࣗ෼ͷύοέʔδ͕ೖΔͷخ͍͠ɻ ࢖ͬͯ΋Β͑Δͱࣗ৴ʹ΋ͳΔɻ

Slide 24

Slide 24 text

͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠