Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29929

Sending email with laravel, but doesn't recognize variable

$
0
0

I'm trying to send an email through Laravel, but I'm getting this error:

Undefined variable: contactEmail

Even though it got defined above it. What is going wrong here?

Controller

$contactName = Input::get('name');
$contactEmail = Input::get('email');
$contactMessage = Input::get('message');

$data = array('name'=>$contactName, 'email'=>$contactEmail, 'message'=>$contactMessage);
Mail::send('template.mail', $data, function($message)
{   
    $message->from($contactEmail, $contactName);
    $message->to('info@aallouch.com', 'myName')->subject('Mail via aallouch.com');
});

EDIT:

template.mail

Name: {{$name}}
Email: {{$email}}
Message:{{$message}}

Viewing all articles
Browse latest Browse all 29929


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>