I have a laravel project in which I need to send emails. Locally it works perfectly but when I upload it to a web hosting it stops working. Do I have to change something to move it to production?
Controller:
class merluzaController extends Controller
{
public function mail(request $request){
$datos=[
"nombre"=>$request->nombre,
"apellido"=>$request->apellido,
"correo"=>$request->correoE,
"numeroT"=>$request->numeroT,
"mensaje"=>$request->mensaje,
];
Mail::send('emails.mails', $datos, function ($message) {
$message->to("[email protected]", "Lucas")->subject('Página de MerluzaDePincho');
});
Session::flash('mensaje_enviado','Mensaje enviado correctamente.');
return redirect('/contacto');
}
}
SEND:
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster@sandbox8f7345b6f0f14762871d8489a6a672c9.mailgun.org
MAIL_PASSWORD=****************
MAIL_ENCRYPTION=null
[email protected]
MAIL_FROM_NAME="Merluza de Pincho"
Apparently it does not reach the redirect in the mail method, why it stops at this link: https://merluzadepincho.000webhostapp.com/mail?name=Lucas&apellido=asd&correoE=asd&numeroT=asd&mensaje=mensaje+de+prasdueba&enviar=Enviar
Ok, now I can understand my mistake. When I imported the class instead of "Facades" it had "facades" written. It is rare that locally it does not give me errors but it does in production. Thank you very much.