Return after sending email

0

In laravel 5.3, at the time of sending the email it does not return anything. Would you like to return some data to see if the email was sent or not?

Something like this:

$mail = Mail::to('[email protected]')->send(new ContatoEmail($dados));

if($mail) {
   //Email enviado
}
else {
   //Falha ao enviar email
}

Please, folks. Can you help me?

    
asked by anonymous 16.05.2018 / 19:47

2 answers

0

You can try something like this:

//Verificando se tem falha no envio
if (Mail::failures()) {

} else {
  //Não houve falha de envio
}
    
30.05.2018 / 14:14
0

The call to send() method will return the number of emails that were delivered or 0 in case of failure.

You can do something like this:

$mail = Mail::to('[email protected]')->send(new ContatoEmail($dados));

if(0 != $mail) {
   //Email enviado
}
else {
   //Falha ao enviar email
}
    
30.05.2018 / 14:44