ENHANCEMENT #4043 Allow setting the from address for debug information in SS_LogEmailWriter - thanks Hamish!

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99845 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-02-24 23:05:42 +00:00 committed by Sam Minnee
parent d2f4b6e071
commit e3bf1384e7

View File

@ -13,6 +13,11 @@ require_once 'Zend/Log/Writer/Abstract.php';
class SS_LogEmailWriter extends Zend_Log_Writer_Abstract {
/**
* @var $send_from Email address to send log information from
*/
protected static $send_from = 'errors@silverstripe.com';
protected $emailAddress;
protected $customSmtpServer;
@ -22,6 +27,14 @@ class SS_LogEmailWriter extends Zend_Log_Writer_Abstract {
$this->customSmtpServer = $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.
@ -41,7 +54,12 @@ class SS_LogEmailWriter extends Zend_Log_Writer_Abstract {
// 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: errors@silverstripe.com");
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);