$ composer require guzzlehttp/guzzle
config/mail.php
1 2 3 4 | 'from' => [ 'address' => env( 'MAIL_FROM_ADDRESS' , 'test@hpscript.com' ), 'name' => env( 'MAIL_FROM_NAME' , 'Hpscript' ), ], |
.env
1 2 3 4 5 6 7 8 | MAIL_MAILER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=${userName} MAIL_PASSWORD=${password} MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=null MAIL_FROM_NAME="${APP_NAME}" |
$ php artisan make:mail TestMail
app/Mail/TestMail.php
1 2 3 4 5 6 7 | public function build() { return $this ->from( "test@hpscript" ) ->subject( "test send" ) ->view( 'email.test' ); } |
resources/views/email/test.blade.php
1 | test mail body |
$ php artisan make:controller –resource MailController
Route
1 | Route::get( '/mail' , [App\Http\Controllers\MailController:: class , 'index' ]); |
app/Http/Controllers/MailController.php
1 2 3 4 5 6 7 8 9 | use Illuminate\Support\Facades\Mail; use App\Mail\TestMail; public function index() { // Mail::to( 'test@example.com' ) ->send( new TestMail()); } |
mailtrapはいいけど、実際に送れないと意味ない。
メール設計書を作成して、mailgunを使っていきます。