Skip to content
Zane Hooper edited this page Mar 10, 2017 · 2 revisions

If necessary, add an Email Template using a Migration.

Then, create a class that extends App\Mail\EmailListener. It should look something like this:

namespace App\Client\Listeners;

use App\Client\Events\ClientPasswordReset;
use App\Mail\EmailListener;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class ClientPasswordResetEmail extends EmailListener
{
    /**
     * Handle the event.
     *
     * @param  ClientPasswordReset  $event
     * @return void
     */
    public function handle(ClientPasswordReset $event)
    {
        $client = $event->client;
        $context = [
            'name' => $client->name,
        ];
        $this->create('client_password_reset.tpl')
            ->setData($context)
            ->toUser($client)
            ->send();
    }
}

Where client_password_reset.tpl is the name of the created email template. Add this class as a listener for the Event that should send the email.