I have a simple site build with Lumen and I need to send emails using Mandrill.
I have set up in the .env file:
MAIL_DRIVER=mandrill
MAIL_HOST=smtp.mandrillapp.com
MAIL_PORT=587
MAIL_USERNAME=mandrill_username
MAIL_PASSWORD=mandrill_api_key
MAIL_FROM_ADDRESS=email_address
MAIL_FROM_NAME=email_name
In the route test I added this code, just to check if it works:
Mail::send( 'emails.gift', $dati, function ( $message ) use ( $dati )
{
$message->to( $dati['email'], $dati['nome'] . ' ' . $dati['cognome'] )->subject( 'Scarica il tuo regalo.' );
} );
But when I try to send the email I get:
ErrorException in TransportManager.php line 116:
Undefined index: secret
In Lumen there is no the services.php file, so where should I set the secret?
You can create your own services.php file. With the path: your-lumen-project/config/services.php same as Laravel services.php path
your-lumen-project/
app/
config/
services.php
services.php content:
<?php
return [
'mandrill' => [
'secret' => env('MANDRILL_SECRET')
],
];
Then put MANDRILL_SECRET=yoursecretkey in your .env file.
Done!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With