summaryrefslogtreecommitdiffstats
path: root/etc/inc/notices.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2009-08-25 14:37:08 -0400
committerScott Ullrich <sullrich@pfsense.org>2009-08-25 14:37:08 -0400
commitb19369b76bb403662b0b61093f5352dfd01082ca (patch)
tree8f944f47f1fe79198ccbcb65bd3ae0fb01af1277 /etc/inc/notices.inc
parent98301932bb99c4577e938f9b7fd61b78d78ecbef (diff)
downloadpfsense-b19369b76bb403662b0b61093f5352dfd01082ca.zip
pfsense-b19369b76bb403662b0b61093f5352dfd01082ca.tar.gz
Adding SMTP support. Ticket #59
Diffstat (limited to 'etc/inc/notices.inc')
-rw-r--r--etc/inc/notices.inc44
1 files changed, 44 insertions, 0 deletions
diff --git a/etc/inc/notices.inc b/etc/inc/notices.inc
index 2f8e5fa..c354b05 100644
--- a/etc/inc/notices.inc
+++ b/etc/inc/notices.inc
@@ -72,6 +72,7 @@ function file_notice($id, $notice, $category = "General", $url = "", $priority =
led_normalize();
led_morse(1, 'sos');
notify_via_growl($notice);
+ notify_via_smtp($notice);
return $queuekey;
}
@@ -190,6 +191,49 @@ function are_notices_pending($category = "all") {
return false;
}
+/****f* pfsense-utils/notify_via_smtp
+ * NAME
+ * notify_via_smtp
+ * INPUTS
+ * notification string to send as an email
+ * RESULT
+ * returns true if message was sent
+ ******/
+function notify_via_growl($message) {
+ require_once("smtp.inc");
+ global $config;
+
+ if(!$config['notifications']['smtp']['ipaddress'])
+ return;
+
+ $smtp = new smtp_class;
+
+ $from = "pfsense@{$config['system']['hostname']}.{$config['system']['domain']}";
+ $to = $config['notifications']['smtp']['notifyemailaddress'];
+
+ $smtp->host_name = $config['notifications']['smtp']['ipaddress'];
+ $smtp->host_port = 25;
+
+ $smtp->direct_delivery = 1;
+ $smtp->ssl = 0;
+ $smtp->debug = 1;
+ $smtp->html_debug = 0;
+
+ $headers = array(
+ "From: {$from}",
+ "To: {$to}",
+ "Subject: {$config['system']['hostname']}.{$config['system']['domain']} - Notification",
+ "Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
+ );
+
+ if($smtp->SendMessage($from, array($to), $headers, $message))
+ echo "Message sent to {$to} OK.\n";
+ else
+ echo "Cound not send the message to {$to}.\nError: {$smtp->error}\n";
+
+}
+
+
/****f* pfsense-utils/notify_via_growl
* NAME
* notify_via_growl
OpenPOWER on IntegriCloud