add mail notification
diff --git a/src/log.c b/src/log.c
index 1a5ad25..0a1b61a 100644
--- a/src/log.c
+++ b/src/log.c
@@ -583,6 +583,40 @@
}
}
+
+void Emaila(const char *fmt, ...)
+{
+ va_list argp;
+ char buf[200];
+ char alertcmd[200];
+ int sysreturn;
+
+ if (global.email_alert) {
+ va_start(argp, fmt);
+ vsnprintf(buf,100,fmt, argp);
+ /*if no from address is set use default */
+ if (!strcmp(global.email_from,"na")) {
+ snprintf(alertcmd,200,"echo \" %s\" | mail -s \"Loadbalancer layer7 alert\" %s &",buf,global.email_to);
+ sysreturn = system(alertcmd);
+ if (sysreturn == -1) {
+ Warning("There was an error sending the email alert");
+ }
+
+ }
+ else {
+ snprintf(alertcmd,200,"echo \" %s\" | mail -s \"Loadbalancer layer7 alert\" %s -a \"From:<%s>\" &",buf,global.email_to,global.email_from);
+ sysreturn = system(alertcmd);
+ if (sysreturn == -1) {
+ Warning("There was an error sending the email alert");
+ }
+ }
+ vfprintf(stderr, fmt, argp);
+ fflush(stderr);
+ va_end(argp);
+ }
+}
+
+
/*
* Displays the message on <out> only if quiet mode is not set.
*/