Using Laravel 5, I need 2 different views for password reset email. The default path to the email view is emails.password. But upon some conditions, I want to send emails.password_alternative.
How can I do this? (with PasswordBroker from Laravel)
This is my current code:
public function __construct(Guard $auth, PasswordBroker $passwords)
{
$this->auth = $auth;
$this->passwords = $passwords;
}
public function sendReset(PasswordResetRequest $request)
{
//HERE : If something, use another email view instead of the default one from the config file
$response = $this->passwords->sendResetLink($request->only('email'), function($m)
{
$m->subject($this->getEmailSubject());
});
}
For anyone interested in Laravel 5.2 you can set a custom html and text email view for password reset by adding
config(['auth.passwords.users.email' => ['auth.emails.password.html', 'auth.emails.password.text']]);
to the PasswordController.php in the constructor before the middleware call.
This overrides the app/config/auth.php setup for the PasswordBroker.
Blade Template for the password reset email is then located at:
yourprojectname/resources/views/auth/emails/password/html.blade.php yourprojectname/resources/views/auth/emails/password/text.blade.php
Took me long enough.
Credits: http://ericlbarnes.com/2015/10/14/how-to-send-both-html-and-plain-text-password-reset-emails-in-laravel-5-1/ http://academe.co.uk/2014/01/laravel-multipart-registration-and-reminder-emails/
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