/** Get class name in model format from class format * @param string $class_name * @return string */ public static function get_model_from_class($class_name) { return ucfirsts($class_name, self::SEP_CLASS, self::SEP_MODEL); }
/** Send email message object * @return int */ public function send() { try { $disable = \System\Settings::get('dev', 'disable', 'offcom'); } catch (\System\Error\Config $e) { $disable = false; } try { $fallback_to = \System\Settings::get('offcom', 'mail_to'); } catch (\System\Error\Config $e) { $fallback_to = null; } $this->validate(); $body = array(); $headers_str = array(); if ($fallback_to) { $rcpt = $fallback_to; } else { $rcpt = implode(', ', $this->rcpt); } $headers = $this->get_default_headers(); $headers['From'] = $this->get_sender(); $headers['Subject'] = $this->get_encoded_subject(); if ($this->reply_to) { if (self::is_addr_valid($this->reply_to)) { $headers['Reply-To'] = $this->reply_to; } else { throw new \System\Error\Format(sprintf('Reply-To "%s" is not formatted according to RFC 2822.', $this->reply_to)); } } foreach ($headers as $header => $value) { $headers_str[] = ucfirsts($header, '-', '-') . ": " . $value; } $body[] = implode("\n", $headers_str) . "\n"; $body[] = strip_tags($this->message); $body = implode("\n", $body); $this->status = self::STATUS_SENDING; if (!$disable) { if (mail($rcpt, $this->get_encoded_subject(), '', $body)) { $this->status = self::STATUS_SENT; } else { $this->status = self::STATUS_FAILED; } } return $this->status; }