普通网友 2015-12-02 10:57
浏览 12

Laravel 5邮件不起作用

I'm working right now with a Laravel 5.1, for some reason my code, even thou it looks fine, doesn't work properly.

I'm trying to make my app send an email with a view as a message.

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'));

}

That's how my controller looks like right know, it basically gets the data from an input and fetch some other information from the database, then it is supposed to save that data in other table, (that'll be used to track some information for an app). After that it should send a message, but even thou my .env file is set up correctly I'm not receiving any emails. Rest of the code works as I wanted it to.

Any idea what might make this script not working?

  • 写回答

1条回答 默认 最新

  • dop82210 2015-12-02 11:54
    关注

    Use PHPMailer, if you are doing it in the local it wont work.PHPMailer will configure your php.ini file and then you will surely get the mail.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么