getSetting("email_from_address"); if ($setting) { $from = $setting; } return $from; } static private function getHtmlTemplate($content) { $wwwroot = WWW_ROOT; $template = << Dippler
Dippler
$content
Dippler
EOT; return $template; } static public function sendPlain($from, $to, $subject, $message) { $header_eol = "\r\n"; if (is_callable('mb_encode_mimeheader')) { $subject = mb_encode_mimeheader($subject, "UTF-8", "B"); } $headers = "From: $from{$header_eol}" . "Content-Type: text/plain; charset=UTF-8; format=flowed{$header_eol}" . "MIME-Version: 1.0{$header_eol}" . "Content-Transfer-Encoding: 8bit{$header_eol}"; return mail($to, $subject, $message, $headers); } static public function sendHtml($from, $to, $subject, $message) { $header_eol = "\r\n"; if (is_callable('mb_encode_mimeheader')) { $subject = mb_encode_mimeheader($subject, "UTF-8", "B"); } $headers = "From: $from{$header_eol}" . "Content-Type: text/html; charset=UTF-8{$header_eol}" . "MIME-Version: 1.0{$header_eol}" . "Content-Transfer-Encoding: 8bit{$header_eol}"; return mail($to, $subject, $message, $headers); } static public function sendAccountApproved($user) { $subject = _("User account approved"); $content = sprintf(_("

Dear %s,

Your user accout was approved by the administrator. You can log in here:
%s

"), $user->getFirstname(), WWW_ROOT, WWW_ROOT); $from = self::getEmailFrom(); $to = $user->getEmail(); return self::sendHtml($from, $to, $subject, self::getHtmlTemplate($content)); } static public function sendWaitingApproval($unapproved_count, $administrators) { if ($unapproved_count > 0 && is_array($administrators) && sizeof($administrators) > 0) { $subject = _("User accounts waiting for an approval"); $content = sprintf(_("

Dear Dippler administrator,

%s new user accounts are waiting for an approval:
%s

"), $unapproved_count, WWW_ROOT."administrate/approve", WWW_ROOT."administrate/approve"); $content = self::getHtmlTemplate($content); $from = self::getEmailFrom(); foreach ($administrators as $administrator) { self::sendHtml($from, $administrator->getEmail(), $subject, $content); } } } }