title: How can I send Email in Laravel command instead of controller
body: <p>I'm working on a project using Laravel where I want to be able to send an email when it is scheduled to send. </p>
  
  <p>So far I've only found solutions to send a mail through a Route but I want to be able to send the mail when cron activates my self made command. I've already made a view of the mail that should be sent and made a page sendMail with <code>php artisan make:mail sendMail</code> that returns the mail view. </p>
  
  <p>sendMail.php</p>
  
  <pre><code> &lt;?php
  
   namespace App\Mail;
   use Illuminate\Support\Facades\DB;
   use Illuminate\Bus\Queueable;
   use Illuminate\Contracts\Queue\ShouldQueue;
   use Illuminate\Mail\Mailable;
   use Illuminate\Queue\SerializesModels;
  
  class sendMail extends Mailable
   { 
       use Queueable, SerializesModels;
  
  /**
   * Create a new message instance.
   *
   * @return void
   */
  public function __construct()
  {
      $winnersposts = DB::select('select post_id from winners group by post_id');
      $posts = DB::select('select * from posts ');
  
      $this-&gt;winnerposts =$winnersposts;
      $this-&gt;posts=$posts;
  }
  
  /**
   * Build the message.
   *
   * @return $this
   */
  public function build()
  {
  
      return $this -&gt;from('ivanrompa@gmail.com')
                   -&gt;view('emails.template');
  }
  </code></pre>
  
  <p>}</p>
  
  <p>mailAdmin.php</p>
  
  <pre><code>public function handle()
  {
  
  }
  </code></pre>
  
  <p>My command handle is still empty but I previously tried to implement to logic from my controller above in my command but it didn't work.</p>
  
  <p>Am I writing the wrong code and is that the reason it just doesn't work or should I approach it in a different way? It is maybe good to know that I am still learning Laravel and I have never sent an email before through code. Any tips or solutions are welcome.</p>