Santiagom
Santiagom

Reputation: 5

Send mail Laravel

I want to send mail through laravel UN and have the following code in a file called enviarEmail.php

$datos = [$correo = $_POST['correo'], $asunto = $_POST['asunto'], $mensaje = $_POST['mensaje'], $adjunto = $_POST['adjunto']];

        Mail::send('emails.contact',$datos,function($msj) use ($datos)
        {
            $msj->to($correo);
            $msj->subject($asunto);
            $msj->getSwitfMessage($mensaje);
            $msj->attach($adjunto);

        }); 

        Session::flash('message','Enviado correctamente');
        return redirect()->back();

?>

and to my knowledge he sends these parameters to this file in the folder emails

<html>
<head>
<title></title>
</head>
    <body>
        <p><strong>Email:</strong>{!!$correo!!}</p>
        <p><strong>Asunto:</strong>{!!$asunto!!}</p>
        <p><strong>Mensaje:</strong>{!!$mensaje!!}</p>
        <p><strong>Adjunto:</strong>{!!$adjunto!!}</p>
    </body>

but tells me that $correo is undefined what should I do ?

Upvotes: 0

Views: 445

Answers (1)

aynber
aynber

Reputation: 23034

Your array doesn't seem to be defined correctly. Use this instead:

$datos = ['correo' => $_POST['correo'], 'asunto' => $_POST['asunto'], 'mensaje' => $_POST['mensaje'], 'adjunto' => $_POST['adjunto']];

Upvotes: 1

Related Questions