Mail::send(), content were being posted before the authentication was attached
According to SendGrid's docs for Laravel Integration, they recommend the following settings:
return array( 'driver' => 'smtp', 'host' => 'smtp.sendgrid.net', 'port' => 587, 'from' => array('address' => '[email protected]', 'name' => 'John Smith'), 'encryption' => 'tls', 'username' => 'sendgrid_username', 'password' => 'sendgrid_password', ); ?>
Here's the code snippet they provide for testing email:
Mail::send('emails.demo', $data, function($message) { $message->to('[email protected]', 'Jane Doe')->subject('This is a demo!'); }); ?>
I was receiving 500 Status errors. However I could connect using telnet and was authenticated. It turned out my emails were being posted before the authentication was attached. My Authentication credentials were set up in the .env file like they are supposed to be. In order to get the 200 Status Success messages I had to hardcode my username and password into the config/mail.php file.
Is there a way around this? I wouldn't want to explicitly code the authentication information in the config/mail.php file. Isn't that the whole point in placing it in the .env file? I was wondering why the authentication info was arriving last, which SendGrid told me was causing them to respond with a 550 error.
I can't replicate this.