/**
  * @return void
  */
 public function notify($areas)
 {
     $options = ['list_id' => NewsletterList::getListId('apply-reminder'), 'subject' => 'Ultimele zile de înscrieri la FII Practic', 'from_name' => 'FII Practic', 'from_email' => '*****@*****.**', 'to_name' => 'Utilizator FII Practic'];
     $body = view('emails.apply-reminder', ['areas' => $areas])->render();
     $content = ['html' => $body, 'text' => strip_tags($body)];
     $campaign = $this->mailchimp->campaigns->create('regular', $options, $content);
     $this->mailchimp->campaigns->send($campaign['id']);
 }
Exemple #2
0
 /**
  * @return void
  */
 public function notify()
 {
     $options = ['list_id' => NewsletterList::getListId('rejected-applicants'), 'subject' => 'Răspuns FII Practic', 'from_name' => 'FII Practic', 'from_email' => '*****@*****.**', 'to_name' => 'Utilizator FII Practic'];
     $body = view('emails.rejected')->render();
     $content = ['html' => $body, 'text' => strip_tags($body)];
     $campaign = $this->mailchimp->campaigns->create('regular', $options, $content);
     $this->mailchimp->campaigns->send($campaign['id']);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $listName = $this->argument('list');
     $tid = config('auth.trainer_role_id');
     $users = User::where('county_id', 20)->get();
     foreach ($users as $user) {
         if (!$user->responses()->count() && (int) $user->role_id !== $tid) {
             echo $user->email . "\n";
             try {
                 $this->list->subscribeTo($listName, $user->email);
             } catch (\Mailchimp_ValidationError $e) {
                 echo $e->getMessage();
             }
         }
     }
     // $emails = [];
     // $failed = [];
     // foreach (Response::all() as $respoonse)
     // {
     // 	$email = $respoonse->user->email;
     // 	if (in_array($email, $emails)) continue;
     // 	if ( ! $respoonse->user->groups()->count('id'))
     // 	{
     // 		$emails[] = $email;
     // 		echo $email . "\n";
     // 		try
     // 		{
     // 			$this->list->subscribeTo($listName, $email);
     // 		}
     // 		catch (\Mailchimp_ValidationError $e)
     // 		{
     // 			echo $e->getMessage();
     // 			$failed[] = $email;
     // 		}
     // 	}
     // }
     // echo count($emails)." users added.\n".count($failed)." failed.";
     // $list = $this->list->getList();
     // $listId = $this->list->getListId($listName);
     // //print_r( $list->interestGroupings($listId) );
     // //exit;
     // $options = [
     //           'list_id' => $listId,
     //           'subject' => 'Test campaign',
     //           'from_name' => 'FII Practic',
     //           'from_email' => '*****@*****.**',
     //           'to_name' => 'Utilizator FII Practic'
     //       ];
     //       $content = [
     //           'html' => 'This is a test campaign',
     //           'text' => 'This is a test campaign'
     //       ];
     //       $segmentOpts = [
     //       	'match'=>'all',
     //       	'conditions' => [
     //       		[
     //       			'field' => 'interests-2113',
     //       			'op' => 'one',
     //       			'value' => 'GrupaA'
     //       		]
     //       	]
     //       ];
     //$mailchimp = new \Mailchimp;
     //$campaign = $mailchimp->campaigns->create('regular', $options, $content, $segmentOpts);
     // $mailchimp->campaigns->send($campaign['id']);
     // $this->list->getList()->interestGroupingAdd($listId, 'Test group', 'checkboxes', ['GrupaA', 'GroupB']);
     // $this->list->subscribeTo($listName, '*****@*****.**', [
     // 	'groupings' => [
     // 		'name' => 'Test group',
     // 		'groups' => ['GrupaA'],
     // 	]
     // ]);
 }