lundi 27 mai 2019

Sending email passing name in laravel

I'm trying to send an email to a user by entering his name and I look for the user's email with this name, but it does not work, the success message appears but in my email I receive nothing. what am I doing wrong?

if(User::where('name', '=', $destinatario)->exists()){
        $exists = DB::table('users')
        ->select('email')
        ->where('name', $destinatario)
        ->get();
        Mail::to($exists)->send(new TestEmail($remetente, $nome, $assunto, $exists, $mensagem));
        return back()->with('sucess', 'Message sent!');
    }else{
        return back()->with('error', 'User does not exist!');
    }

Mailable:

public function __construct($remetente, $nome, $assunto, $destinatario, $data)
{
    $this->remetente = $remetente;
    $this->nome = $nome;
    $this->assunto = $assunto;
    $this->destinatario = $destinatario;
    $this->data = $data;
}

public function build()
{
    //$address = 'gabriel.jg04@gmail.com';
    $subject = 'E-mail de Usuário';
    $name = 'Juelito';

    return $this->view('emails.test',['texto'=>$this->data])
                ->from($this->remetente, $this->nome)
                ->replyTo($this->destinatario, $name)
                ->subject($this->assunto);           
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire