title: Send Email Using SendGrid in Laravel 8
body: <p>I'm trying to setup SendGrid to send emails in my Laravel 8 project. I've been following this documentation:</p>
  <p><a href="https://sendgrid.com/docs/for-developers/sending-email/laravel/" rel="nofollow noreferrer">https://sendgrid.com/docs/for-developers/sending-email/laravel/</a></p>
  <p>I copied the .env mail setup the way they have it. I just add my sendgrid api key in the password field, and added my sendgrid verified email in the &quot;MAIL_FROM_ADDRESS&quot;.</p>
  <pre><code>MAIL_MAILER=smtp
  # MAIL_DRIVER=smtp # for laravel &lt; 7
  MAIL_HOST=smtp.sendgrid.net
  MAIL_PORT=587
  MAIL_USERNAME=apikey
  MAIL_PASSWORD=MY_SENDGRID_API_KEY
  MAIL_ENCRYPTION=tls
  MAIL_FROM_NAME=&quot;MY NAME&quot;
  MAIL_FROM_ADDRESS=MY VERIFIED EMAIL FROM SENDGRID
  </code></pre>
  <p>Then it asks me to do a php artisan make:mail TestEmail (&quot;app/Mail/TestEmail.php&quot;) and copy the following code:</p>
  <pre><code>&lt;?php
  
  namespace App\Mail;
  
  use Illuminate\Bus\Queueable;
  use Illuminate\Mail\Mailable;
  use Illuminate\Queue\SerializesModels;
  use Illuminate\Contracts\Queue\ShouldQueue;
  
  class TestEmail extends Mailable
  {
      use Queueable, SerializesModels;
  
      public $data;
  
      public function __construct($data)
      {
          $this-&gt;data = $data;
      }
  
      public function build()
      {
          $address = 'MY VERIFIED SENDGRID EMAIL ADDRESS';
          $subject = 'This is a test!';
          $name = 'MY NAME';
  
          return $this-&gt;view('emails.test')
                      -&gt;from($address, $name)
                      -&gt;cc($address, $name)
                      -&gt;bcc($address, $name)
                      -&gt;replyTo($address, $name)
                      -&gt;subject($subject)
                      -&gt;with([ 'test_message' =&gt; $this-&gt;data['message'] ]);
      }
  }
  </code></pre>
  <p>Then I created a view in &quot;app/resources/views/emails/test.blade.php&quot;:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en-US&quot;&gt;
    &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot; /&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h2&gt;Test Email&lt;/h2&gt;
      &lt;p&gt;{{ $test_message }}&lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  Sendi
  </code></pre>
  <p>Then it tells me to send the email with the following code:</p>
  <pre><code>    &lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  
  use App\Mail\TestEmail;
  
  use Illuminate\Support\Facades\Mail;
  
  class SendGridEmailController extends Controller
  {
      public function sendMail()
      {
          $data = ['message' =&gt; 'This is a test!'];
  
          Mail::to('MY GMAIL ACCONT')-&gt;send(new TestEmail($data));
      }
  }
  </code></pre>
  <p>For the above code, the documentation didn't say to create a controller or anything, but in my situation I did created a controller &quot;SendGridEmailController&quot; and added the above code there.</p>
  <p>Then, in my routes/web.php file, I created a route:</p>
  <pre><code>Route::get('/test_email', [SendGridEmailController::class, 'sendMail']);
  </code></pre>
  <p>Then, when I try to run the code by going to the above route, I get this error:</p>
  <p>&quot;Address in mailbox given [mailtrap] does not comply with RFC 2822, 3.6.2.&quot;</p>
  <p>I don't understand what this error is trying to say. I tried looking up at Google search and even here, but I couldn't find anything that relates to what I'm facing in Laravel.</p>
  <p>Maybe I miss something or did not setup sendgrid properly?</p>
  <p>I appreciate your help on this. Thank you!</p>