Speak Person, one more trouble, is as follows:
I'm trying to send an email through my application (api), where I develop with Laravel 5.4. The thing seems very easy, just not!
My .env file looks like this:
MAIL_DRIVER=smtp
MAIL_HOST=mail.estilosoft.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=meAjuda123
MAIL_ENCRYPTION=null
Include the same password, for you to test and see that I am not passing the wrong information
I have a model called Contact, in it I have the function email () as follows:
public function email($dados){
Mail::send('contatoEmail',$dados, function ($message){
$message->subject('E-Mail Example');
$message->from('[email protected]','Contato');
$message->to('[email protected]');
});
if(Mail::failures())
return Mail::failures();
else
return true;
}
I also have a ContactController, which makes the call in the function:
namespace App\Http\Controllers;
use App\Contato;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class ContatoController extends Controller{
public function store(Request $request){
$validator = Validator::make($request->all(), [
'nome' => 'required',
'sobrenome' => 'required',
'email' => 'required',
'telefone' => 'required',
'assunto' => 'required',
'departamento_id'=> 'required',
'mensagem' => 'required',
]);
if ($validator->fails()) {
return response()->json(['erro'=> true, 'mensagem'=>'Formato de dados inválidos!','data'=>$request->all()], 401);
}
$contato = new Contato();
$contato->fill($request->all());
if($contato->save()){
if($contato->email($request->all())){
return response()->json(['erro'=> false, 'mensagem'=>'Mensagem salva, email enviado!','data'=>$contato], 201);
}else{
return response()->json(['erro'=> false, 'mensagem'=>'Mensagem salva!','data'=>$contato], 201);
}
}else{
return response()->json(['erro'=> true, 'mensagem'=>'Não conseguimos salvar sua solicitação','data'=>$contato], 201);
}
}
} // class
And to end the problem, or rather, to start the problem, the damn error, which happens when trying to send the email:
I think it's not relevant to post something about the view, but if I need to, I can post it.