Beispiel #1
0
 function guimails($dataemails)
 {
     // get input
     //$to = $emails
     //$tos = preg_split("/[\s;]+/", $to);
     //$cc = \Input::get('nguoinhankhac');
     //$ccs = preg_split("/[\s;]+/", $cc);
     //$subject = $dataemails->tieude;
     //$message = $dataemails->noidungemail;
     //dd($dataemails);
     //echo '<pre>';
     //print_r($ccs);
     //$toEmails = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**');
     $toEmails = Danhmucemail::getdanhsachnguoinhan($dataemails['emails']);
     //$paths = File::getduongdanfileemail($dataemails['attachfiles']);
     //dd($toEmails);
     /*
         \Mail::send('layout.emails', $dataemails , function ($dataemails) use ($paths, $toEmails) {
     
             //$message->from('*****@*****.**', '');
     
             $dataemails->to($toEmails)->subject('hello');
     
             $size = count($paths);
             for ($i = 0; $i < $size; $i++) {
                 $dataemails->attach($paths[$i]);
             }
             //dd($dataemails);
         });
     */
     //dd($toEmails);
     \Mail::send('layout.emails', $dataemails, function ($dataemails) use($toEmails) {
         //$message->from('*****@*****.**', '');
         $dataemails->to($toEmails)->subject('hello');
         echo 'ok';
     });
     //return $sent = 'ok';
     // has file
     /*
     if (\Input::hasFile('attachment')) {
         $now_date = str_replace('/', '_', date('d/m/Y'));
         $files = \Input::file('attachment');
         $newnamefiles = array();
         foreach ($files as $file) {
             $destinationPath = 'uploads';
             $filename = $file->getClientOriginalName();
             $filename = File::removesign($filename);
             $filename = File::removespace($filename);
             $newfilename = $now_date . '_' . rand(1, 99999) . '_' . $filename;
             $upload_success = $file->move($destinationPath, $newfilename);
             array_push($newnamefiles, $newfilename);
         }
     
         $path = array();
     
         foreach ($newnamefiles as $value) {
             $filepath = 'uploads/' . $value;
             array_push($path, $filepath);
         }
     
         // không cc
         if ($ccs[0] == '') {
             \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use ($path, $tos, $ccs, $subject) {
                 $message->from('*****@*****.**', 'Lê Thanh Thái');
     
                 $message->to($tos)->subject($subject);
     
     
                 $size = count($path);
                 for ($i = 0; $i < $size; $i++) {
                     $message->attach($path[$i]);
                 }
             });
             return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!');
         } else {
             \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use ($path, $tos, $ccs, $subject) {
                 $message->from('*****@*****.**', 'Lê Thanh Thái');
     
                 $message->to($tos)->cc($ccs)->subject($subject);
     
     
                 $size = count($path);
                 for ($i = 0; $i < $size; $i++) {
                     $message->attach($path[$i]);
                 }
             });
             return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!');
         }
     
     } else // no file
     {
         if ($ccs[0] == '') {
             \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use ($tos, $ccs, $subject) {
                 $message->from('*****@*****.**', 'Lê Thanh Thái');
     
                 $message->to($tos)->subject($subject);
     
             });
             return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!');
         } else {
             \Mail::send('emails.mail', array('user_message' => \Input::get('noidung')), function ($message) use ($tos, $ccs, $subject) {
                 $message->from('*****@*****.**', 'Lê Thanh Thái');
     
                 $message->to($tos)->cc($ccs)->subject($subject);
     
             });
             return \Redirect::route('email.send')->with('message', 'Gửi Thành Công!');
         }
     
     }//end send
     */
 }