[英]sending email in localhost via laravel 4.2 using gmail mail driver
我試圖使用laravel 4和gmail郵件驅動程序發送電子郵件,我已經將config/mail.php
文件更改為如下所示:
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,
);
這是我控制器內的代碼
Mail::send('view', $data, function($message)
{
$message->to(Input::get('SupplierEmail') , 'Jon Doe')->subject('Sample Mail!');
});
我有點迷失了我將在“視圖”部分放的內容,這里的$ data部分是我的視圖的樣子
這是我視圖中表單的代碼
{{ 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()}}
提前致謝
該view
是用於電子郵件正文的模板。
http://laravel.com/docs/4.2/mail提供了有關如何執行此操作的更多信息。
您的視圖文件如下所示:
<body>
Hello {{ $data->name }}
</body>
您需要添加映射到控制器的路由:
Route::post('addpurchorder', 'PurchaseController@doStuff');
然后將您的驗證和上面的mailer函數添加到doStuff
方法中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.