public function updateCustomRecord($parameters) { $account = ['name_013' => $this->request->input('name'), 'email_013' => $this->request->input('email'), 'reply_to_013' => empty($this->request->input('replyTo')) ? null : $this->request->input('replyTo'), 'outgoing_server_013' => $this->request->input('outgoingServer'), 'outgoing_user_013' => $this->request->input('outgoingUser'), 'outgoing_secure_013' => $this->request->input('outgoingSecure'), 'outgoing_port_013' => $this->request->input('outgoingPort'), 'incoming_type_013' => $this->request->input('incomingType'), 'incoming_server_013' => $this->request->input('incomingServer'), 'incoming_user_013' => $this->request->input('incomingUser'), 'incoming_secure_013' => $this->request->input('incomingSecure'), 'incoming_port_013' => $this->request->input('incomingPort')]; // Get object to read password to check account if ($parameters['specialRules']['outgoingPassRule'] || $parameters['specialRules']['incomingPassRule']) { $oldAccount = EmailAccount::find($this->request->input('id')); } if (!$parameters['specialRules']['outgoingPassRule']) { $account['outgoing_pass_013'] = Crypt::encrypt($this->request->input('outgoingPass')); } else { $account['outgoing_pass_013'] = $oldAccount->outgoing_pass_013; } if (!$parameters['specialRules']['incomingPassRule']) { $account['incoming_pass_013'] = Crypt::encrypt($this->request->input('incomingPass')); } else { $account['incoming_pass_013'] = $oldAccount->incoming_pass_013; } $response = EmailServices::testEmailAccount($account); if ($response === true) { EmailAccount::where('id_013', $this->request->input('id'))->update($account); } else { return redirect()->route('edit' . ucfirst($this->routeSuffix), $parameters['urlParameters'])->withErrors($response)->withInput(); } }
/** * Function which directly sends a test campaign group * * @access public * @param array $paramenters * @return void */ public static function sendEmailsTest($paramenters) { $campaign = EmailCampaign::builder()->where('id_044', $paramenters['id'])->first(); $testGroup = Preference::getValue('emailServiceTestGroup', 5); $contacts = Contact::getRecords(['group_id_042' => (int) $testGroup->value_018, 'groupBy' => 'id_041']); if (count($contacts) > 0) { foreach ($contacts as $contact) { if ($contact->email_041 != null) { $dataEmail = ['replyTo' => empty($campaign->reply_to_013) ? null : $campaign->reply_to_013, 'email' => $contact->email_041, 'html' => $campaign->header_044 . $campaign->body_044 . $campaign->footer_044, 'text' => $campaign->text_044, 'subject' => $campaign->subject_044, 'contactKey' => Crypt::encrypt($contact->id_041), 'company' => isset($contact->company_041) ? $contact->company_041 : '', 'name' => isset($contact->name_041) ? $contact->name_041 : '', 'surname' => isset($contact->surname_041) ? $contact->surname_041 : '', 'birthDate' => isset($contact->birth_date_041) ? date(config('pulsar.datePattern'), $contact->birth_date_041) : '', 'campaign' => Crypt::encrypt($campaign->id_044), 'historyId' => '0']; // config SMTP account config(['mail.host' => $campaign->outgoing_server_013]); config(['mail.port' => $campaign->outgoing_port_013]); config(['mail.from' => ['address' => $campaign->email_013, 'name' => $campaign->name_013]]); config(['mail.encryption' => $campaign->outgoing_secure_013 == 'null' ? null : $campaign->outgoing_secure_013]); config(['mail.username' => $campaign->outgoing_user_013]); config(['mail.password' => Crypt::decrypt($campaign->outgoing_pass_013)]); EmailServices::sendEmail($dataEmail); } } } }
public function previewCampaign() { // get parameters from url route $parameters = $this->request->route()->parameters(); // function to view online the campaign $emailCampaign = EmailCampaign::find(Crypt::decrypt($parameters['campaign'])); // We check that the historyId exists and is equal to 0, // It is 0 when the request comes from a campaign preview if (isset($parameters['historyId']) && $parameters['historyId'] !== '0') { $emailSendHistorical = EmailSendHistory::builder()->where('id_048', Crypt::decrypt($parameters['historyId']))->first(); } // if is a test mailing, set contactKey and historyId to 0 $data = ['email' => isset($emailSendHistorical->email_041) ? $emailSendHistorical->email_041 : null, 'html' => $emailCampaign->header_044 . $emailCampaign->body_044 . $emailCampaign->footer_044, 'subject' => $emailCampaign->subject_044, 'campaign' => Crypt::encrypt($emailCampaign->id_044), 'contactKey' => isset($emailSendHistorical->id_041) ? Crypt::encrypt($emailSendHistorical->id_041) : '0', 'company' => isset($emailSendHistorical->company_041) ? $emailSendHistorical->company_041 : null, 'name' => isset($emailSendHistorical->name_041) ? $emailSendHistorical->name_041 : null, 'surname' => isset($emailSendHistorical->surname_041) ? $emailSendHistorical->surname_041 : null, 'birthDay' => isset($emailSendHistorical->birth_date_041) ? date(config('pulsar.datePattern'), $emailSendHistorical->birth_date_041) : null, 'historyId' => isset($parameters['historyId']) ? $parameters['historyId'] : '0']; $data = EmailServices::setTemplate($data); return view('pulsar::common.views.html_display', $data); }