Exemple #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     $cont = Contacto::find($id);
     $telefones = Telefone::where('contacto_id', '=', $id)->get();
     $emails = Email::where('contacto_id', '=', $id)->get();
     return view("contacto", ['cont' => $cont]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     // error_log("------------------------------------------------------");
     $Mailer = new Email();
     $Mailer->email = $request['email'];
     /* $validator class with method fails() */
     $validator = Validator::make($request->all(), ['email' => 'required|email']);
     /* $isNewEmail =
                true: no email found in db
                false: duplicate email found in db
        */
     $isNewEmail = collect($Mailer->where('email', $Mailer->email)->get())->isEmpty() ? true : false;
     if ($validator->fails()) {
         error_log(json_encode(['error' => ['invalid_email' => $request->all()]]));
         return response()->json(['error' => 'E-mail is invalid'])->setCallback($request->input('callback'));
     } elseif (!$isNewEmail) {
         error_log(json_encode(['error' => ['duplicate_email' => $request->all()]]));
         return response()->json(['error' => 'E-mail is marked as being subscribed'])->setCallback($request->input('callback'));
         return redirect('/')->withErrors($validator)->withInput();
     } else {
         error_log(json_encode(['mailer' => ['newEmail' => $Mailer]]));
         // soon
         $Scribe = $this->subscribe($Mailer->email);
         // soon
         error_log(json_encode(['scribe' => $Scribe]));
         $Mailer->save();
         return response()->json(['success' => true])->setCallback($request->input('callback'));
     }
 }
 public function renderEmail($title_slug, Request $request)
 {
     $touch = Touch::where('title_slug', '=', $title_slug)->first();
     if (!$touch) {
         abort(404);
     }
     if ($request->input('email')) {
         $salted_id = $request->input('email');
     } else {
         $salted_id = null;
     }
     if ($salted_id) {
         $email = Email::where('salted_id', $salted_id)->first();
         $html = preg_replace_callback('/{{[^}]*}}/', function ($matches) use($email) {
             return collect($matches)->map(function ($match) use($email) {
                 $match = str_replace('{{', '', $match);
                 $match = str_replace('}}', '', $match);
                 $match = trim($match);
                 if ($match === 'tracking') {
                     return $email->salted_id;
                 }
                 return $email->contact->{$match};
             })->first();
         }, $email->touch->template_html);
     } else {
         $html = $touch->template_html;
     }
     return view('emails.template')->with(['template_html' => $html, 'salted_id' => $salted_id, 'campaign' => $touch->campaign, 'email' => false, 'preview_text' => $touch->preview_text]);
 }
 public function overview()
 {
     $data['inbox_count'] = Email::where('user_id', Auth::id())->where('box_id', 1)->count();
     //todo: if you want to write articles, contact us
     $articles = Article::where('user_id', Auth::id())->orderBy('id', 'asc')->get();
     $sites = Auth::user()->sites()->get();
     $professions = Auth::user()->professions()->get();
     $classifieds = Classified::where('user_id', Auth::id())->orderBy('id', 'desc')->get();
     return view('dashboard.overview', compact('data', 'articles', 'sites', 'professions', 'classifieds'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     /*
     $resultsa = User::with('Email')
         ->whereHas('Email', function($q)
         {
             $q->where('user_id',Auth::user()->id);
     
         })->get();
     dd($resultsa);
     */
     $results = Email::where('user_id', Auth::user()->id)->get();
     return view('app.email.index', compact('results'));
 }
Exemple #6
0
 public function getModel()
 {
     if (\Auth::check()) {
         return \Auth::user();
     }
     if ($this->request->hasCookie('email_user')) {
         $user = Email::where('email', $this->request->cookie('email_user'));
     }
     if ($this->request->hasCookie('guest_user')) {
         $tracker = $this->request->cookie('guest_user');
     }
     $tracker = $this->request->getClientIp();
     $user = Guest::firstOrCreate(['identifier' => $tracker]);
     return $user;
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function editUser($slug)
 {
     //
     $user = User::where('slug', '=', $slug)->first();
     $number = Number::where('user_id', '=', $user->id)->get();
     $mail = Email::where('user_id', '=', $user->id)->get();
     $option[0] = $user;
     $option[1] = $number;
     $option[2] = $mail;
     //dd($option);
     return view('frontend.edit', compact('option'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy()
 {
     Email::where('email', '=', Request::get('email'))->delete();
     return redirect('/')->with('update', 'Sorry to see you go!');
 }
 private function addContactsToCampaign($campaign)
 {
     $contacts = Email::where('campaign_id', '=', $campaign->id)->lists('contact_id')->toArray();
     $campaign->contacts()->sync($contacts);
 }
 public function open_email(Request $request)
 {
     $cam_id = $request->cam_id;
     $to = $request->to;
     $email = Email::where('campaign_id', $cam_id)->where('to', $to)->first();
     if ($email->status == 1) {
         $email->status = 3;
     }
     $email->save();
 }
 public function queueEmails($id)
 {
     $touch = Touch::find($id);
     $signups = array_column($touch->campaign->signups->toArray(), 'contact_id');
     $contactIds = array_column($touch->campaign->contacts->toArray(), 'id');
     $sentContactIds = Email::where('touch_id', $touch->id)->where('trackable', true)->groupBy('contact_id')->lists('contact_id')->toArray();
     $unsentContactIds = array_diff($contactIds, $sentContactIds, $signups);
     $queuedEmails = 0;
     foreach ($unsentContactIds as $contact_id) {
         $contact = Contact::find($contact_id);
         if (!$contact->unsubscribe && !$contact->bounced) {
             $email = Email::create(['subject' => $touch->subject, 'reply_to' => $touch->campaign->client->reply_to, 'from' => $touch->campaign->client->reply_to, 'send_on' => $touch->send_on, 'template' => "emails.{$touch->template}", 'draft' => false, 'trackable' => true, 'campaign_id' => $touch->campaign->id, 'contact_id' => $contact->id, 'touch_id' => $touch->id]);
             $email->salted_id = bcrypt($email->id);
             $email->save();
             $queuedEmails++;
         }
     }
     return redirect()->back()->with('message', "{$queuedEmails} emails queued");
 }
 public function updEmails($persona_id, $request)
 {
     if ($request->get('email') != '') {
         // Al permitir varios emails, esto tiene que cambiar
         $email = Email::firstOrNew(['persona_id' => $persona_id]);
         $email->fill($request->all());
         $email->persona_id = $persona_id;
         $email->save();
     } else {
         $email = Email::where('persona_id', $persona_id)->first();
         if (!is_null($email)) {
             $email->delete();
         }
     }
 }
Exemple #13
0
// Password reset routes...
Route::get('password/reset/{token}', 'Auth\\PasswordController@getReset');
Route::post('password/reset', 'Auth\\PasswordController@postReset');
Route::get('halloween_email', ['as' => 'halloween', function (Request $request) {
    if ($request->input('email')) {
        $salted_id = $request->input('email');
        $request->session()->put('salted_id', $salted_id);
    } else {
        $salted_id = $request->session()->get('salted_id', null);
    }
    return view('emails.halloween')->with(['salted_id' => $salted_id, 'email' => false]);
}]);
Route::get('tracking', ['as' => 'tracking', function (Request $request) {
    if ($request->input('email')) {
        $salted_id = $request->input('email');
        $email = Email::where('salted_id', '=', $salted_id)->first();
        if ($email && $email->trackable) {
            $action = Action::firstOrCreate(['action' => 'opened', 'contact_id' => $email->contact->id, 'campaign_id' => $email->campaign->id, 'touch_id' => $email->touch_id]);
        }
    }
    return \Image::canvas(10, 10)->encode('gif');
}]);
Route::get('emails/{title_slug}', ['as' => 'emails', 'uses' => 'EmailController@renderEmail']);
Route::get('ep_vikings_signup', ['as' => 'ep_vikings_signup', 'uses' => 'SignupController@epVikingsSignup']);
Route::post('ep_vikings_signup', ['as' => 'ep_vikings_submit', 'uses' => 'SignupController@epVikingsSubmit']);
Route::get('engage_signup', ['as' => 'engage_signup_generic', 'uses' => 'SignupController@engageGeneric']);
Route::post('engage_signup', ['as' => 'engage_signup_redirect', 'uses' => 'SignupController@engageRedirect']);
Route::get('engage_signup/{name}', ['as' => 'engage_signup', 'uses' => 'SignupController@engage']);
Route::post('signup', ['as' => 'signup', 'uses' => 'SignupController@signup']);
Route::post('signup/forward', ['as' => 'signup.forward', 'uses' => 'SignupController@signupForward']);
Route::get('testmail', function () {
 public function engage($name, Request $request)
 {
     $email = $request->input('email') ? Email::where('salted_id', '=', $request->input('email'))->first() : null;
     $touch = $email ? $email->touch : Touch::where('title_slug', '=', $name)->first();
     $campaign = $touch->campaign;
     if ($email && $email->trackable) {
         Action::firstOrCreate(['action' => 'clicked register', 'contact_id' => $email->contact->id, 'campaign_id' => $email->campaign->id, 'touch_id' => $email->touch_id]);
     }
     return view()->make('signups.engage')->with(['campaign' => $campaign, 'email' => $email]);
 }
Exemple #15
0
 public function processEmail($message)
 {
     if (Email::where('gmail_uid', $message->id)->count() == 0) {
         $mail = new Email();
         $service = Mailbox::getGmailService();
         $user = '******';
         try {
             $message_data = $service->users_messages->get($user, $message->id);
         } catch (Exception $e) {
             print 'An error occurred: ' . $e->getMessage();
         }
         foreach ($message_data->getPayload()->headers as $header) {
             if ($header['name'] == 'Subject') {
                 $mail->subject = $header['value'];
             }
             if ($header['name'] == 'Cc') {
                 $mail->cc = $header['value'];
             }
             if ($header['name'] == 'From') {
                 $from_pos = strpos($header['value'], "<");
                 $from_name = substr($header['value'], 0, $from_pos);
                 $from_address = substr($header['value'], $from_pos + 1, -1);
                 $mail->sender_name = $from_name;
                 $mail->sender_address = $from_address;
             }
             if ($header['name'] == 'Date') {
                 $mail->received_at = Carbon::createFromFormat('D, d M Y H:i:s T', $header['value']);
             }
         }
         $mail->mailbox_id = $this->id;
         $attachments = new Collection();
         if ($message_data->getPayload()->body['size'] == 0) {
             foreach ($message_data->getPayload()->parts as $part) {
                 if (count($part->parts) > 0) {
                     foreach ($part->parts as $subpart) {
                         if ($subpart->mimeType == 'text/html') {
                             $mail->mimetype = 'text/html';
                             $mail->content = base64_decode(strtr($subpart->getBody()->data, '-_,', '+/='));
                         }
                     }
                 }
                 if ($part->mimeType == 'text/html') {
                     $mail->mimetype = 'text/html';
                     $mail->content = base64_decode(strtr($part->getBody()->data, '-_,', '+/='));
                 }
                 if ($part['filename'] != '') {
                     $attachment_data = $service->users_messages_attachments->get("me", $message->id, $part->getBody()->attachmentId);
                     $file_raw_data = base64_decode(strtr($attachment_data->data, array('-' => '+', '_' => '/')));
                     $stored_filename = $message->id . '-' . time() . '-' . $part['filename'];
                     $fh = fopen(public_path() . "/email_attachments/" . $stored_filename, "w+");
                     fwrite($fh, $file_raw_data);
                     fclose($fh);
                     $attachment = new EmailAttachment();
                     $attachment->file_path = "email_attachments/" . $stored_filename;
                     $attachment->file_name = $part['filename'];
                     $attachment->save();
                     $attachments->push($attachment);
                 }
             }
             if (!$mail->content) {
                 foreach ($message_data->getPayload()->parts as $part) {
                     if ($part->mimeType == 'text/plain') {
                         $mail->mimetype = 'text/plain';
                         $mail->content = base64_decode(strtr($part->getBody()->data, '-_,', '+/='));
                     }
                 }
             }
         } else {
             $mail->mimetype = 'text/plain';
             $mail->content = base64_decode(strtr($message_data->getPayload()->body['data'], '-_,', '+/='));
         }
         $mail->gmail_uid = $message->id;
         $mail->save();
         if ($attachments->count() > 0) {
             foreach ($attachments as $a) {
                 $a->email_id = $mail->id;
                 $a->save();
             }
         }
         $mail->matchToPatient();
         $mail->addProcessedLabel();
     }
 }