Example #1
0
 public static function getCampaignsNotCreated()
 {
     return EmailCampaign::where('shipping_date_044', '<', date('U'))->where('created_044', false)->get();
 }
Example #2
0
 /**
  *  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 recordStatistic()
 {
     // get parameters from url route
     $parameters = $this->request->route()->parameters();
     // if it's a test email, we brake execution
     if ($parameters['historyId'] === '0') {
         exit;
     }
     $campaign = Crypt::decrypt($parameters['campaign']);
     $historyId = Crypt::decrypt($parameters['historyId']);
     // add a viewed to the campaign
     EmailCampaign::where('id_044', $campaign)->increment('viewed_044');
     // add a viewed to the historical
     EmailSendHistory::where('id_048', $historyId)->increment('viewed_048');
 }