<?php

namespace App\Listeners;

use App\Mail\FeedbackSender;
use Illuminate\Support\Facades\Mail;

class SendFeedbackMessage {
    public function __construct() {
    }

    public function handle(object $event) {
        try {
//            $array = [
//                'email' => $event->email,
//                'data' => $event->data,
//            ];
//            mail('sergey@bodin.ru', 'Array', print_r($array, 1));
            Mail::to($event->email)->send(new FeedbackSender($event->data));
//            Mail::raw("Testing", function ($message) {
//                $message->to('sergey@bodin.ru', 'Jim')->subject('LaravelGMail App!');
//            });
        } catch (\Exception $exception) {
            mail('sergey@bodin.ru', 'Error', $exception->getMessage());
        }
    }
}
