2016-02-17 115 views
0

我想通過laravel聯合國來發送郵件,並在一個名爲enviarEmail.php發送郵件Laravel

文件下面的代碼
$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(); 

?>

據我所知,他將這些參數傳遞給該文件在文件夾中的郵件

<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> 

,但告訴我,$郵報未定義什麼我應該怎麼做?

+0

你確定你有$ _POST ['correo']嗎? –

+0

如果,當然,$ _ post發佈所有值 – Santiagom

回答

1

你的數組似乎沒有被正確定義。用這個代替:

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