private function send(\string $template_name, User $to_user, array $data) { $base_path = __DIR__ . self::$FOLDER_PATH . DIRECTORY_SEPARATOR . $template_name . DIRECTORY_SEPARATOR; $body_html = file_get_contents($base_path . self::$HTML_FILE_NAME); $body_text = file_get_contents($base_path . self::$TEXT_FILE_NAME); foreach ($data as $key => $var) { $body_html = str_replace("#!" . $key . "!#", $var, $body_html); $body_text = str_replace("#!" . $key . "!#", $var, $body_text); } $body_html = str_replace("#!BASE_URL!#", Config::getBaseUrl(), $body_html); $body_text = str_replace("#!BASE_URL!#", Config::getBaseUrl(), $body_text); $address = $this->is_dev ? Config::getDevUserEmail() : $to_user->getEmailUniversity(); $this->_phpmailer->addAddress($address, $to_user->getNameFull()); $this->_phpmailer->msgHTML($body_html); $this->_phpmailer->AltBody = $body_text; $this->logEmail($this->_phpmailer->send(), $template_name, $to_user, $data); $this->_phpmailer->clearAllRecipients(); $this->_phpmailer->clearAttachments(); $this->_phpmailer->clearReplyTos(); }