emailAddress = $emailAddress; $this->customSmtpServer = $customSmtpServer; } static function factory($emailAddress, $customSmtpServer = false) { return new SS_LogEmailWriter($emailAddress, $customSmtpServer); } public static function set_send_from($address) { self::$send_from = $address; } public static function get_send_from() { return self::$send_from; } /** * Send an email to the email address set in * this writer. */ public function _write($event) { // If no formatter set up, use the default if(!$this->_formatter) { $formatter = new SS_LogErrorEmailFormatter(); $this->setFormatter($formatter); } $formattedData = $this->_formatter->format($event); $subject = $formattedData['subject']; $data = $formattedData['data']; $originalSMTP = ini_get('SMTP'); // override the SMTP server with a custom one if required if($this->customSmtpServer) ini_set('SMTP', $this->customSmtpServer); mail( $this->emailAddress, $subject, $data, "Content-type: text/html\nFrom: " . self::$send_from ); // reset the SMTP server to the original if($this->customSmtpServer) ini_set('SMTP', $originalSMTP); } }