protected function generateEmail()
 {
     $data = ['to' => '*****@*****.**', 'send_type' => 'queue', 'subject' => 'Test', 'html' => '<html></html>'];
     return Email::create($data);
 }
示例#2
0
 private function send($method = 'post', $data = null)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->url);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     curl_setopt($ch, CURLOPT_HEADER, false);
     $file_contents = curl_exec($ch);
     curl_close($ch);
     $res = json_decode($file_contents);
     $opts = ['to' => $this->to, 'mail_type' => $this->mail_type, 'deliver_at' => date('Y-m-d H:i:s')];
     foreach ($res as $key => $val) {
         $opts[$key] = $val;
     }
     Email::create($opts);
     return $res;
 }
示例#3
0
 /**
  * Save a new Email model and return the instance.
  *
  * @access protected
  * @param  Request $request
  * @return Email|null - en caso de error.
  */
 protected function newEmail(Request $request)
 {
     $email = null;
     try {
         DB::beginTransaction();
         $email = Email::create(['stand' => $request->get('stand'), 'empresa' => $request->get('empresa'), 'email' => $request->get('email'), 'telefono' => $request->get('telefono'), 'mensaje' => $request->get('mensaje'), 'plantilla_id' => $request->get('plantilla'), 'usuario_id' => auth()->user()->id]);
         if ($email->save() === true) {
             $email->logotipo = $this->saveImage($request->file('logotipo'), $email->id);
             $email->contactos()->saveMany($this->contactos($request->get('contactos')));
             $email->save();
         }
         DB::commit();
     } catch (Exception $e) {
         DB::rollBack();
         Log::error($e);
         $email = null;
     }
     return $email;
 }