2016-08-04 2 views

답변

0

: 나는 콘솔에서 실행하고있는 명령은

namespace App\Console; 

use Illuminate\Console\Scheduling\Schedule; 
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; 

class Kernel extends ConsoleKernel 
{ 
    /** 
    * The Artisan commands provided by your application. 
    * 
    * @var array 
    */ 
    protected $commands = [ 
     Commands\Inspire::class, 
     Commands\SendEmails::class, 
    ]; 

    /** 
    * Define the application's command schedule. 
    * 
    * @param \Illuminate\Console\Scheduling\Schedule $schedule 
    * @return void 
    */ 
    protected function schedule(Schedule $schedule) 
    //{ 
    // $schedule->command('inspire')->everyMinute(); 
    //} 
} 

:

namespace App\Console\Commands; 

use Illuminate\Console\Command; 
use Illuminate\Support\Facades\Mail; 

class SendEmails extends Command 
{ 
    /** 
    * The name and signature of the console command. 
    * 
    * @var string 
    */ 
    protected $signature = 'emails:send'; 

    /** 
    * The console command description. 
    * 
    * @var string 
    */ 
    protected $description = 'Command description'; 

    /** 
    * Create a new command instance. 
    * 
    * @return void 
    */ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    /** 
    * Execute the console command. 
    * 
    * @return mixed 
    */ 
    public function handle() 
    { 
     try { 
      Mail::send('emails.testmail', [ ], function ($m) { 
       $m->to('[email protected]', 'Francisco Larios')->subject('Your Reminder!'); 
      }); 
     } catch (\Exception $e) { 
      throw new \Exception("Error Processing Request", 1); 

     } 

    } 
} 

커널 파일의 코드는 다음입니다 문제는 내가 전자 메일을 보내려는 SMTP 서버였습니다. mail.php 연결 파일에서 다른 SMTP 서버로 변경했습니다. 응용 프로그램과 명령 줄 실행 모두에서 작동합니다.

관련 문제