Laravel 5.2 reset password + Mandrill

2019-08-10 20:34发布

问题:

I have Laravel 5.2 fresh installation.

I did following:

  1. I have set up my .env file MAIL_DRIVER=mandrill SECRET=my_mandrill_api_key
  2. I have installed Guzzle (https://github.com/guzzle/guzzle)
  3. I have setup my email in view (https://github.com/laravel/laravel/blob/5.0/resources/views/emails/password.blade.php)
  4. I have fixed the certificate issue (PHP cURL error code 60)

So it seems everything is done correctly.

When I fill email to reset password and press Send Password Reset Link button, I get following error

Server error: POST https://mandrillapp.com/api/1.0/messages/send-raw.json resulted in a 500 Internal Server Error response: {"status":"error","code":-1,"name":"ValidationError","message":"You must specify a key value"}

I have check my log in Mandrill (https://mandrillapp.com/settings/api) there is no logs for my action.

From the error of Mandrill, I know it does not get the api key, so for some reason the api key and other values is not passing over to Mandrill api.

Question: What is missing/wrong?

Note: right now I am working on my local environment building the app. My local environment Windows 10/Bitnami WAMP stack 7/ I am also using Mandrill API.

回答1:

If you are using the Mandrill driver then you must set the MANDRILL_SECRET in your .env file.

The other settings MAIL_HOST, MAIL_PORT and so on are for use with other drivers.

See the documentation here about using the Mandrill driver. It mentions that you should set the Mandrill key in config/services.php but you should really set that using an environment variable, so if you have customized the file change it back to

'mandrill' => [
    'secret' => env('MANDRILL_SECRET'),
],

Then you will be able to read the MANDRILL_SECRET value from the .env file.

So in your .env file you'll have;

MAIL_DRIVER=mandrill
MANDRILL_SECRET=your_mandrill_key_here