diff options
author | Scott Ullrich <sullrich@su.local> | 2009-09-04 20:56:58 -0400 |
---|---|---|
committer | Scott Ullrich <sullrich@su.local> | 2009-09-04 20:56:58 -0400 |
commit | 743c30df06fa412346b477b18cc9bab1e2ff1c28 (patch) | |
tree | 410c54bc3499573bdc5cc9d204509902e5b10bbc /etc/inc/notices.inc | |
parent | fb05887adc9c8a15ba90e49c31ea16899d62a181 (diff) | |
download | pfsense-743c30df06fa412346b477b18cc9bab1e2ff1c28.zip pfsense-743c30df06fa412346b477b18cc9bab1e2ff1c28.tar.gz |
Do not email the same message twice
Diffstat (limited to 'etc/inc/notices.inc')
-rw-r--r-- | etc/inc/notices.inc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/etc/inc/notices.inc b/etc/inc/notices.inc index eaf06ab..d98b131 100644 --- a/etc/inc/notices.inc +++ b/etc/inc/notices.inc @@ -208,6 +208,11 @@ function notify_via_smtp($message) { if(!$config['notifications']['smtp']['notifyemailaddress']) return; + /* Do NOT send the same message twice */ + $lastmsg = trim(file_get_contents("/var/db/notices_lastmsg.txt")); + if($lastmsg == $message) + return; + require_once("smtp.inc"); $smtp = new smtp_class; @@ -230,6 +235,11 @@ function notify_via_smtp($message) { "Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z") ); + /* Store last message sent to avoid spamming */ + $fd = fopen("/var/db/notices_lastmsg.txt", "w"); + fwrite($fd, $message); + fclose($fd); + if($smtp->SendMessage($from, array($to), $headers, $message)) echo "Message sent to {$to} OK.\n"; else |