2016-11-14 7 views
1

私はlaravel 5.3でこのコードを使用して電子メールを送信しています。しかし、私はまだ変数を定義している間、未定義の変数$ emailと言います。 これは私のコードです。laravelで電子メールを送信する5.3

 $user->save(); 
     if (!empty($user->save())) { 
      $email = '[email protected]'; 
      $mail = Mail::send('email_page', ['verification_key' => $verification_code], function($message) { 
      $message->from('[email protected]', 'Verify'); 
      $message->to($email) 
      ->subject('Verify your email address'); 
      }); 
      return view('for_company'); 

      } 

、エラーが未定義の変数です:電子メールあなたのように閉鎖機能にuse()が欠落している

答えて

0

$user->save(); 
    if (!empty($user->save())) { 
     $email = '[email protected]'; 
     $mail = Mail::send('email_page', ['verification_key' => $verification_code], function($message) use($email) { 
     $message->from('[email protected]', 'Verify'); 
     $message->to($email) 
     ->subject('Verify your email address'); 
     }); 
     return view('for_company'); 

     }