Laravel 5邮件不起作用

时间:2015-12-02 10:57:36

标签: php email laravel-5 laravel-facade

我现在正在使用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文件设置正确,我也没有收到任何电子邮件。其余代码按我的意愿工作。

知道什么可能使这个脚本不起作用?

1 个答案:

答案 0 :(得分:0)

使用PHPMailer,如果你在本地做它不会工作.PHPMailer将配置你的php.ini文件,然后你一定会收到邮件。