Skip to content

Commit

Permalink
ENHANCEMENT #4043 Allow setting the from address for debug informatio…
Browse files Browse the repository at this point in the history
…n in SS_LogEmailWriter - thanks Hamish! (from r99845)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105536 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed May 25, 2010
1 parent 4d2cc5d commit 593a87b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion dev/LogEmailWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
*/
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;
Expand All @@ -21,6 +26,14 @@ public function __construct($emailAddress, $customSmtpServer = false) {
$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.
Expand All @@ -40,7 +53,12 @@ public function _write($event) {
// 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);
Expand Down

0 comments on commit 593a87b

Please sign in to comment.