fuel/email にsendgrid のdriverがなかったので自作したのでメモ
1.composer.json の repositories を更新する
1 2 3 4 5 6 7 8 9 10 |
"repositories": [ { "type": "vcs", "url": "https://github.com/fuel/docs" }, { "type": "vcs", "url": "https://github.com/fuel/core" }, { "type": "vcs", "url": "https://github.com/fuel/auth" }, - { "type": "vcs", "url": "https://github.com/fuel/email" }, + { "type": "vcs", "url": "https://github.com/shinn-droid/email" }, { "type": "vcs", "url": "https://github.com/fuel/oil" }, { "type": "vcs", "url": "https://github.com/fuel/orm" }, { "type": "vcs", "url": "https://github.com/fuel/parser" } ], |
2.”fuel/email”を更新する
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// 1.8.0系で使いたい場合 "require": { - "fuel/email": "1.8.0", + "fuel/email": "1.8.0.*", + "sendgrid/sendgrid": "~6.0" ], // 1.8.2系で使いたい場合 "require": { - "fuel/email": "1.8.2", + "fuel/email": "1.8.2.*", + "sendgrid/sendgrid": "~6.0" ], |
3.composer で updateする
1 2 |
php composer.pahr selfupdate php composer.phar update |
1.8.0系の場合、 1.8.0.5 にupdateされればOK
1.8.2系の場合、 1.8.2.sendgrid にupdateされればOK
4.設定ファイル
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php return array( /** * Override default Email.php settings */ 'defaults' => array( 'driver' => 'sendgrid', 'sendgrid' => array( 'apikey' => 'YOUR KEY', ), ), ); |
簡単な使い方
1 2 3 4 5 6 7 8 9 10 11 12 |
$email = \Email::forge('jis'); $email->to(['sample1@example.com', 'sample2@example.com',]); $email->subject('件名を入力'); $email->body('メール本文を入力'); try{ $email->send(); } catch(\EmailSendingFailedException $e) { Log::warning('メール送信に失敗しました。 '.$e); } catch(\EmailValidationFailedException $e) { Log::warning($e); } |
Githubに公開しました
https://github.com/shinn-droid/email/releases/tag/1.8.0.5
利用は自己責任でお願いします
以前の記事