0
Speak Person, one more trouble, it’s as follows:
I am trying to send an email through my application (api), where I develop with Laravel 5.4. The thing seems very easy, just not!
My file . env is as follows:
MAIL_DRIVER=smtp
MAIL_HOST=mail.estilosoft.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=meAjuda123
MAIL_ENCRYPTION=null
Include the password is the same, so you can test and see that I am not passing the wrong information
I have a model called Contact, in it I have Function email() the following form:
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 Contactocontroller, who makes the call in 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 mistake, which happens when trying to send the email:
I don’t think it’s relevant to post something related to the view, but if necessary I can post.