Return after sending email

Asked

Viewed 297 times

0

In Laravel 5.3, at the time of sending the email it does not return anything. It would have to return some data to verify whether the email was sent or not?

Something like that:

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

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

Please guys. Can you help me?

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
}

0

The call to the method send() 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
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.