我现在正在使用 Laravel 5.1,由于某种原因,我的代码,即使你看起来很好,也不能正常工作。
我试图让我的应用程序发送一封带有视图作为消息的电子邮件。
public function sale(Request $request, $id)
{
$laptops = Laptops::findOrFail($id);
$name = Input::get('usr');
$lname = Input::get('lname');
$email = Input::get('email');
$city = Input::get('city');
$street = Input::get('street');
$houseNr = Input::get('houseNr');
$postCode = Input::get('postCode');
$telephone = Input::get('telephone');
$dCity = Input::get('deliveryCity');
$dStreet = Input::get('deliveryStreet');
$dHouseNr = Input::get('deliveryHouseNr');
$dPostCode = Input::get('deliveryPostCode');
$dTelephone = Input::get('deliveryTelephone');
DB::table('orders')->insert([
[
'customerName' => Input::get('usr'),
'customerLastname' => Input::get('lname'),
'customerEmail' => Input::get('email'),
'customerCity' => Input::get('city'),
'customerStreet' => Input::get('street'),
'customerHomeNumber' => Input::get('houseNr'),
'customerPostNumber' => Input::get('postCode'),
'customerPhoneNumber' => Input::get('telephone'),
'customerDeliveryCity' => Input::get('deliveryCity'),
'customerDeliveryStreet' => Input::get('deliveryStreet'),
'customerDeliveryHomeNumber' => Input::get('deliveryHouseNr'),
'customerDeliveryPostNumber' => Input::get('deliveryPostCode'),
'customerDeliveryPhoneNumber' => Input::get('deliveryTelephone'),
'choosenNotebook' => $laptops->name,
'choosenGpu' => $laptops->gpu,
'choosenCpu' => $laptops->cpu,
'choosenRam' => $laptops->ram,
'choosenHdd' => $laptops->hdd,
'choosenSsd' => $laptops->ssd,
'choosenAHdd' => $laptops->hdd2,
'choosenASsd' => $laptops->ssd2,
'choosenOs' => $laptops->os,
'choosenWarranty' => $laptops->warrantyOption,
'orderPrice' => $laptops->price,
]]);
Mail::send('shop.message', ['name' => Input::get('usr'), 'lastname' => Input::get('lname')], function($message)
{
$message->to(Input::get('email'), Input::get('usr'))->from('support@dreammachines.pl')->subject('Informacje dotyczące sprzędaży.');
});
return view('shop.payment', compact('laptops', 'name', 'lname', 'email', 'city', 'street', 'houseNr', 'postCode', 'telephone', 'dCity', 'dStreet', 'dHouseNr', 'dPostCode', 'dTelephone'));
}
这就是我的控制器看起来正确的样子,它基本上从输入中获取数据并从数据库中获取一些其他信息,然后它应该将该数据保存在其他表中,(这将用于跟踪一些信息应用程序)。之后它应该发送一条消息,但即使你我的.env
文件设置正确,我也没有收到任何电子邮件。其余代码按我的意愿工作。
知道什么可能使该脚本无法正常工作吗?