load->model($models); } function sendTheEmail( $to, $subject, $html, $cc = FALSE){ $this->load->library( 'email' ); $result = "Success"; if ( ! is_array( $to ) ) $to = (array) $to; foreach ( $to as $receiver ){ $mailParts = explode( '@', $receiver ); if (! $mailParts || count($mailParts) < 2) return $result="Er gaat iets fout met e-mail adres ".$receiver; $this->email->to( $receiver ); $this->email->from( 'info@monpas.nl', 'Framework MonPas' ); if ( $cc ) $this->email->bcc( $cc ); $this->email->subject( $subject ); $this->email->message( $html ); $sendResult = $this->email->send(); if ( ! $sendResult ){ $result = $this->email->print_debugger(); }; } return $result; } private function setmail(){ if ( ENVIRONMENT == 'production' ){ $config['smtp_host'] = $_ENV['MAILGUN']['HOST']; $config['smtp_port'] = $_ENV['MAILGUN']['SMTP_PORT']; $config['smtp_user'] = $_ENV['MAILGUN']['SMTP_USER']; $config['smtp_pass'] = $_ENV['MAILGUN']['SMTP_PASS']; } else { $config['smtp_host'] = $_ENV['MAIL']['HOST']; $config['smtp_port'] = $_ENV['MAIL']['SMTP_PORT']; $config['smtp_user'] = $_ENV['MAIL']['SMTP_USER']; $config['smtp_pass'] = $_ENV['MAIL']['SMTP_PASS']; } $this->email->initialize( $config ); } } // model