lundi 15 juin 2020

How to send a email when import?

I am trying send an email to a user, when a list is import.

But is not working. I am Using Mailtrap.

This is my code here i think where is the problem:

<?php

namespace App\Http\Controllers;

use App\Imports\CsvImport;
use App\Mail\SuccessMail;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Mail;
use Maatwebsite\Excel\Facades\Excel;
use function GuzzleHttp\Promise\all;


class CsvFile extends Controller
{
    function index()
    {
        return view('csv_file');
    }

    public function csv_import()
    {
        Excel::import(new CsvImport, request()->file('file'));
        return redirect('/home');

    }

    public function sendEmail()
    {
        $user = Auth::user();
        Mail::to($user->email)->send(new SuccessMail());
    }

}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire