These are just shorthand notes from setting up SparkPost on a Laravel 5.6 project:
1.) Open up gitbash at the project root and run:
composer require guzzlehttp/guzzle
**If you get the error code below:
file could not be downloaded: allow_url_fopen must be enabled in php.ini (http:// wrapper is disabled in the server configuration by allow_url_fopen=0
**Then SSH into the server and run the command below to fix that:
php -d allow_url_fopen=1 /opt/cpanel/composer/bin/composer update
2.) Open config/mail.php and make sure the driver line is set to
'driver' => env('MAIL_DRIVER', 'log'),
3.) Verify that the following code is in config/services.php
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
4.) Add the following two lines to your .env file and upload:
MAIL_DRIVER=sparkpost
SPARKPOST_SECRET=secret-key-goes-here
Troubleshooting:
After completing the steps above are you getting the error message:
"Connection could not be established with host smtp.mailtrap.io [Connection refused #111]"
Then these steps will fix that error message:
1.) After uploading the new .env file clear the cache by running:
php artisan config:clear and php artisan cache:clear
2.) Get rid of any default mail settings in your .ENV file