Laravel and Mandrill sending to the wrong email address

I recently ran into a problem with Laravel and Mandrill. All the emails were going to myself, rather than the people trying to register on my site. It has been driving me crazy for a few hours.

Turns out the problem was because I had specified "to" in the mail.php config. I was using this as a default address for when someone fills in the contact form, where to send the email too.

So basically if you have 'to' => ['address' => '[email protected]', 'name' => 'James Elliott'] it'll always send to you, rather than where you specify it to go.

E.g.

Mail::send('emails.auth.register', $user->toArray(), function($message) use ($user) {

    $message->from(Config::get('mail.from.address'), Config::get('mail.from.name'))

->to($user->email, $user->firstname . ' ' . $user->lastname)

        ->subject('New registration');
});

Laravel will always override the "to" with what is specified in mail.php.

I worked around this by removing the "to" variable from the mail.php config and instead of using Config::get('mail.to.address') and Config::get('mail.to.name') I use env('MAIL_TO_ADDRESS') and env('MAIL_TO_NAME')