Esempio n. 1
0
	function email_reports() {		$this -> email -> from('*****@*****.**', 'Vaccine Summaries');
		$email_recipients = Email_Recipients::getAll();
		//Retrieve all reports in order to attach them to the email
		$files = directory_map('Summaries');
		//Loop through all files and attach them one by one
		foreach ($files as $file) {
			$this -> email -> attach("Summaries/" . $file);
		}
		$this -> email -> subject('Vaccine Status Summaries For Kenya');
		$this -> email -> message('Vaccine Summaries for all Regional Stores and the Central Vaccine Store are attached.');
		//Retrieve all intended recipients of this email
		foreach ($email_recipients as $recipient) {
			$email = $recipient -> Email;
			$this -> email -> cc($email);
			$this -> email -> send();
			echo $this -> email -> print_debugger();
		}

	}
Esempio n. 2
0
 public function save_recipient()
 {
     $names = $this->input->post("names");
     $emails = $this->input->post("emails");
     $existing_recipients = Email_Recipients::getAll();
     //First delete all the existing plans
     foreach ($existing_recipients as $existing_recipient) {
         $existing_recipient->delete();
     }
     //Then add the new Plans
     $counter = 0;
     foreach ($names as $name) {
         if (strlen($name) > 2) {
             $recipient = new Email_Recipients();
             $recipient->Name = $names[$counter];
             $recipient->Email = $emails[$counter];
             $recipient->save();
             $counter++;
         } else {
             continue;
         }
     }
     redirect("report_management");
 }