fix mail sender issue
diff --git a/src/log.c b/src/log.c
index 0a1b61a..10eb68d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -583,32 +583,46 @@
 	}
 }
 
+void make_literal(char const *input, char *output) { 
+  // the following two arrays must be maintained in matching order:
+  static char inputs[] = "\a\b\f\n\r\t\v\\\"\'";
+  static char outputs[] = "abfnrtv\\\"\'";
+
+  char *p, *pos;
+
+  for (;*input;input++) {
+    if (NULL!= (pos=strchr(inputs, *input))) {
+      *output++ = '\\';
+      *output++ = outputs[pos-inputs];
+    }
+    else
+      *output++ = *input;
+  }
+  *output = '\0';
+}
 
 void Emaila(const char *fmt, ...)
 {
   va_list argp;
-  char buf[200];
-  char alertcmd[200];
+  char tmp[128];
+  char buf[256];
+  char alertcmd[500];
   int sysreturn;  
 
   if (global.email_alert) {
     va_start(argp, fmt);
-    vsnprintf(buf,100,fmt, argp);
+    vsnprintf(tmp,128,fmt, argp);
+    make_literal(tmp, buf);
     /*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");
-      }
-
+      snprintf(alertcmd,500,"echo \" %s\" | mail -s \"HAProxy alert\" %s &",buf,global.email_to);
     }
     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");
-      }
+      snprintf(alertcmd,500,"echo \" %s\" | mail -s \"$(echo -e \"HAProxy alert\\nFrom: HAProxy <%s>\\n\")\" %s &",buf,global.email_from,global.email_to);
+    }
+    sysreturn = system(alertcmd);
+    if (sysreturn == -1) {
+      Warning("There was an error sending the email alert");
     }
     vfprintf(stderr, fmt, argp);
     fflush(stderr);