Hi Im trying to send a mail but when I try using the Mail::Send but the variables im creating to have the information to which mail it will be send wont go into the Mail::Send part. I dont know why it always tells me undifined variable, when its defined right on top. Here is the code
$result = DB::table('perfil')->where('usuario', $object['usuario'])->first();
$info = array('confirmation_code' => $result->codigoVerificacion, 'nombre' => $result->nombre);
$mail = $result->correoVerificado;
$nombre = $result->nombre.' '.$result->primerPaterno.' '.$result->segundoApellido;
Mail::send('emails.registro_nuevo_usuario', $info, function($message)
{
$message->from('[email protected]', 'Jurgen Feuchter');
$message->to($mail, $nombre)
->subject('¡Bienvenido a la mejor red social para pedir y dar rides!');
});
If you need more code ask me for it please :P
'Undefined variable: mail' in \app\controllers\registroController.php:103
$mail
comes from outside the closure, so it's not available inside its scope (unlike $message
which is passed down as argument by the send()
method). You need to pass it by using the use
keyword (I believe the same will happen to $nombre
)
Mail::send('emails.registro_nuevo_usuario', $info, function($message) use($mail, $nombre)
{
$message->from('[email protected]', 'Jurgen Feuchter')
->to($mail, $nombre)
->subject('¡Bienvenido a la mejor red social para pedir y dar rides!');
});