im trying to send an email using laravel 4 and using the gmail mail driver i've already changed my config/mail.php
file into something like this:
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'email_that_im_using', 'name' => 'Trial'),
'encryption' => 'ssl',
'username' => 'mygmailusername',
'password' => 'mygmailpassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
and here is my code inside the controller
Mail::send('view', $data, function($message)
{
$message->to(Input::get('SupplierEmail') , 'Jon Doe')->subject('Sample Mail!');
});
im kinda lost on what will i put on the 'view' part and the $data part here is what my view looks like
and here is the code of my form inside my view
{{ Form::open(array('url' => 'addpurchorder')) }}
<div class="form-group">
{{ Form::label('module', 'Select Module: ') }}
{{ Form::select('ModuleInfo', [null=>'Please Select Module'] + $modules , Input::old('ModuleInfo'), array('class'=>'form-control'))}}
</div>
<div class="form-group">
{{ Form::label('qty', 'Quantity') }}
{{ Form::text('Quantity', Input::old('Quantity'), array('class' => 'form-control','placeholder' => 'Enter Quantity')) }}
</div>
<div class="form-group">
<h4><i><span class="label label-success">NOTE: Default Status is pending</span></i></h4>
</div>
<div class="form-group">
{{ Form::label('from', 'School Email (From)') }}
{{ Form::text('SchoolEmail', Input::old('SchoolEmail'), array('class' => 'form-control','placeholder' => 'Enter School Email')) }}
</div>
<div class="form-group">
{{ Form::label('to', 'Supplier Email (To)') }}
{{ Form::text('SupplierEmail', Input::old('SupplierEmail'), array('class' => 'form-control','placeholder' => 'Enter Supplier Email')) }}
</div>
<div class="form-group">
{{ Form::label('captcha', 'CAPTCHA image: ') }}
</br>
{{ HTML::image('http://localhost:8080/laravel3/app/captcha.php', 'alt' , array( 'width' => 250, 'height' => 43 )) }} </br></br>
{{ Form::text('capt', Input::old('capt'), array('class' => 'form-control','placeholder' => 'enter generated captcha')) }}
</div>
{{ Form::submit('Create Purchase Order', array('class' => 'btn btn-primary')) }}
{{ Form::close()}}
thanks in advance
The view
is the template that is be used for the email's body.
http://laravel.com/docs/4.2/mail gives more information about how to do it.
your view file can look like this:
<body>
Hello {{ $data->name }}
</body>
You need to add a route that maps to a controller:
Route::post('addpurchorder', 'PurchaseController@doStuff');
Then add your validation, and mailer function above to the doStuff
method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.