public static function mail($to, $subject, $message, $from = '*****@*****.**') { //Send e-mails only in production environments if (Configuration::getEnvironment() == Environment::PRODUCTION) { // Do a little spring cleaning $to = trim(preg_replace('#[\\n\\r]+#s', '', $to)); $subject = trim(preg_replace('#[\\n\\r]+#s', '', $subject)); $from = trim(preg_replace('#[\\n\\r:]+#s', '', $from)); $headers = 'From: ' . $from . "\r\n" . 'Date: ' . date('r') . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-transfer-encoding: 8bit' . "\r\n" . 'Content-type: text/plain; charset=iso-8859-1' . "\r\n"; mail($to, $subject, $message, $headers); } //Log the e-mail $logger = Logger::getInstance(); $logStr = "Sent e-mail [env: " . Configuration::getEnvironment() . "]\n [to: " . $to . "] [subject: " . $subject . "] [message: " . $message . "]"; $logger->log($logStr, Logger::INFO, Util::PACKAGE); }