Index: trunk/src/sh_error.c
===================================================================
--- trunk/src/sh_error.c	(revision 271)
+++ trunk/src/sh_error.c	(revision 272)
@@ -1332,4 +1332,81 @@
 /*@i@*/}
 
+#if defined(SH_WITH_MAIL)
+void sh_error_mail (const char * alias, int sev, 
+		    const char * file, long line, 
+		    long status, unsigned long msg_id, ...)
+{
+  va_list         vl;                 /* argument list          */
+  struct _log_t * lmsg;
+
+  int    severity;
+  unsigned int class;
+  char * fmt;
+  int retval; 
+
+  SL_ENTER(_("sh_error_mail"));
+
+  /* Returns pointer to (constant|thread-specific) static memory
+   */
+  fmt = /*@i@*/get_format (msg_id, &severity, &class);
+
+  if (!fmt)
+    {
+      SL_RET0(_("sh_error_mail"));
+    }
+
+  /* --- Override the catalogue severity. ---
+   */
+  if (sev != (-1))
+    severity = sev;
+
+  /* --- Build the message. ---
+   */
+  lmsg = (struct _log_t *) SH_ALLOC(sizeof(struct _log_t));
+  MLOCK( (char *) lmsg, sizeof(struct _log_t));
+  /*@i@*/lmsg->msg = NULL;
+
+  /*@i@*/(void) sl_strlcpy(lmsg->format, fmt, SH_PATHBUF);
+  (void) sl_strlcpy(lmsg->file, file, SH_PATHBUF);
+  lmsg->severity = severity;
+  lmsg->class    = (int) class;
+  lmsg->line     = line;
+  lmsg->status   = status;
+
+  /* Format the log message with timestamp etc.
+   * Allocate lmsg->msg
+   */
+  va_start (vl, msg_id);
+  (void) sh_error_string (lmsg, vl);
+  va_end (vl);
+
+  if ( (severity & SH_ERR_FATAL) == 0) 
+    retval = sh_nmail_pushstack (severity, lmsg->msg, alias);
+  else 
+    retval = sh_nmail_msg (severity, lmsg->msg, alias);
+  
+  if (retval == -2)
+    {
+      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_QUEUE_FULL,
+		       _("email"));
+    }
+  SL_RET0(_("sh_error_mail"));
+}
+#else
+void sh_error_mail (const char * alias, int sev, 
+		    const char * file, long line, 
+		    long status, unsigned long msg_id, ...)
+{
+  (void) alias;
+  (void) sev;
+  (void) file;
+  (void) line;
+  (void) status;
+  (void) msg_id;
+
+  return;
+}
+/* defined(SH_WITH_MAIL) */
+#endif 
 
 /* -------------------------  
Index: trunk/src/sh_fifo.c
===================================================================
--- trunk/src/sh_fifo.c	(revision 271)
+++ trunk/src/sh_fifo.c	(revision 272)
@@ -44,9 +44,12 @@
 #define SH_FIFO_MARKED 4
 
-/* Prepare an email message and return it.
+/* Prepare an email message and return it. Iterate over list on stack and
+ * check for each if it is valid for recipient 'tag'. If yes, add to the
+ * returned string.
+ * okNull == False means that item->s_xtra must be defined
  */
 sh_string * tag_list (SH_FIFO * fifo, char * tag,
 		      int(*valid)(int, const char*, const char*, const void*),
-		      const void * info)
+		      const void * info, int okNull)
 {
   struct dlist * item;
@@ -59,6 +62,8 @@
       while (item)
 	{
+	  /* Same recipient, or no recipient ( := all )
+	   */
 	  if ( (tag && item->s_xtra && 0 == strcmp(item->s_xtra, tag)) ||
-	       !(item->s_xtra) )
+	       ((okNull == S_TRUE) && !(item->s_xtra)) )
 	    {
 	      if (valid == NULL)
@@ -68,4 +73,5 @@
 	      else
 		{
+		  /* level, message, recipient, list */
 		  if (!valid(item->i_xtra, item->data, tag, info))
 		    goto skipped;
Index: trunk/src/sh_getopt.c
===================================================================
--- trunk/src/sh_getopt.c	(revision 271)
+++ trunk/src/sh_getopt.c	(revision 272)
@@ -454,4 +454,9 @@
   fputs (_(" using time server"), stdout); ++num;
 #endif
+#if defined(HAVE_REGEX_H)
+  if (num > 0) fputc ('\n', stdout);
+  fputs (_(" posix regex support"), stdout); ++num;
+#endif
+
 
 #if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE)
Index: trunk/src/sh_log_check.c
===================================================================
--- trunk/src/sh_log_check.c	(revision 271)
+++ trunk/src/sh_log_check.c	(revision 272)
@@ -1179,5 +1179,5 @@
 
 /* Define a reporting queue.
- * Format: Label : [Interval] : TYPE : Severity
+ * Format: Label : [Interval] : TYPE : Severity[:alias]
  * TYPE must be 'report' or 'sum'
  * Interval is ignored for TYPE='report'
Index: trunk/src/sh_log_correlate.c
===================================================================
--- trunk/src/sh_log_correlate.c	(revision 271)
+++ trunk/src/sh_log_correlate.c	(revision 272)
@@ -282,8 +282,19 @@
 	      if (val >= 0)
 		{
+		  sh_string * alias;
 		  SH_MUTEX_LOCK(mutex_thread_nolog);
 		  sh_error_handle (mkeep->queue->severity, FIL__, __LINE__, 0, 
 				   MSG_LOGMON_COR, sh_string_str(mkeep->label),
 				   val);
+
+		  alias = mkeep->queue->alias;
+		  if (alias)
+		    {
+		      sh_error_mail (sh_string_str(alias), 
+				     mkeep->queue->severity, FIL__, __LINE__, 0, 
+				     MSG_LOGMON_COR, sh_string_str(mkeep->label),
+				     val);
+		    }
+		  
 		  SH_MUTEX_UNLOCK(mutex_thread_nolog);
 		}
Index: trunk/src/sh_log_evalrule.c
===================================================================
--- trunk/src/sh_log_evalrule.c	(revision 271)
+++ trunk/src/sh_log_evalrule.c	(revision 272)
@@ -151,4 +151,7 @@
   char **      splits = split_array(new, &nfields, ':', lengths);
 
+  /* group is label:regex
+   */
+
   if (group_open)
     group_open = NULL;
@@ -313,10 +316,10 @@
   struct sh_qeval * nq;
   int     severity;
-  unsigned int nfields = 4; /* label:interval:(report|sum):severity */
-  size_t  lengths[4];
+  unsigned int nfields = 5; /* label:interval:(report|sum):severity[:alias] */
+  size_t  lengths[5];
   char *  new = sh_util_strdup(str);
   char ** splits = split_array(new, &nfields, ':', lengths);
 
-  if (nfields != 4)
+  if (nfields < 4)
     {
       SH_FREE(splits);
@@ -356,4 +359,5 @@
   nq = SH_ALLOC(sizeof(struct sh_qeval));
   nq->label = sh_string_new_from_lchar(splits[0], lengths[0]);
+  nq->alias = NULL;
 
   DEBUG("debug: splits[2] = %s, policy = %d\n",splits[2],nq->policy); 
@@ -368,4 +372,10 @@
 
   nq->severity = severity;
+
+  if (nfields == 5)
+    {
+      nq->alias = sh_string_new_from_lchar(splits[4], lengths[4]);
+    }
+
   nq->next     = queuelist;
   queuelist    = nq;
@@ -408,4 +418,22 @@
   return SH_ERR_SEVERE;
 }
+
+sh_string * sh_log_lookup_alias(const char * str)
+{
+  struct sh_qeval * queue;
+
+  if (str)
+    {
+      if (0 != strcmp(str, _("trash")))
+	{
+	  queue = sh_log_find_queue(str);
+	  
+	  if (queue)
+	    return queue->alias;
+	}
+    }
+  return NULL;
+}
+
 
 static char * get_label_and_time(const char * inprefix, char * str, 
@@ -993,5 +1021,6 @@
 }
 
-static void msg_report(int severity, struct sh_geval * rule, struct sh_logrecord * record)
+static void msg_report(int severity, const sh_string * alias, 
+		       struct sh_geval * rule, struct sh_logrecord * record)
 {
   char      * tmp;
@@ -1017,4 +1046,13 @@
 		   sh_string_str(record->host),
 		   tmp);
+  if (alias)
+    {
+      sh_error_mail (sh_string_str(alias),
+		     severity, FIL__, __LINE__, 0, MSG_LOGMON_REP,
+		     msg,
+		     ttt,
+		     sh_string_str(record->host),
+		     tmp);
+    }
   SH_FREE(ttt);
   SH_FREE(msg);
@@ -1025,5 +1063,6 @@
 }
 
-static void sum_report(int severity, sh_string * host, sh_string * message, sh_string * path)
+static void sum_report(int severity, const sh_string * alias,
+		       sh_string * host, sh_string * message, sh_string * path)
 {
   char * tmp;
@@ -1037,4 +1076,12 @@
 		   sh_string_str(host), 
 		   tmp);
+  if (alias)
+    {
+      sh_error_mail (sh_string_str(alias),
+		     severity, FIL__, __LINE__, 0, MSG_LOGMON_SUM,
+		     msg,
+		     sh_string_str(host),
+		     tmp);
+    }
   SH_FREE(msg);
   SH_FREE(tmp);
@@ -1108,6 +1155,6 @@
     {
       DEBUG("debug: report count\n");
-      sum_report(rule->queue->severity, counter->hostname, 
-		 counter->counted_str, counter->filename);
+      sum_report(rule->queue->severity, rule->queue->alias,
+		 counter->hostname, counter->counted_str, counter->filename);
       counter->start = time(NULL);
       counter->count = 0;
@@ -1131,5 +1178,5 @@
 		 sh_string_str(record->host), 
 		 sh_string_str(record->message));
-	  msg_report(queue->severity, rule, record);
+	  msg_report(queue->severity, queue->alias, rule, record);
 	  retval = 0;
 	}
@@ -1177,5 +1224,5 @@
 	{
 	  DEBUG("debug: (%lu) no rule found\n", i); ++i;
-	  msg_report(DEFAULT_SEVERITY, NULL, record);
+	  msg_report(DEFAULT_SEVERITY, NULL, NULL, record);
 	}
 
Index: trunk/src/sh_log_mark.c
===================================================================
--- trunk/src/sh_log_mark.c	(revision 271)
+++ trunk/src/sh_log_mark.c	(revision 272)
@@ -221,4 +221,5 @@
     {
       int severity;
+      sh_string * alias;
       SH_MUTEX_LOCK(mutex_thread_nolog);
 
@@ -233,4 +234,13 @@
 		       sh_string_str(event->label), 
 		       (unsigned long) delay);
+      alias = sh_log_lookup_alias(sh_string_str(event->queue_id));
+      if (alias)
+	{
+	  sh_error_mail (sh_string_str(alias), severity, 
+			 FIL__, __LINE__, 0, MSG_LOGMON_MARK, 
+			 sh_string_str(event->label), 
+			 (unsigned long) delay);
+	}
+
       SH_MUTEX_UNLOCK(mutex_thread_nolog);
     }
Index: trunk/src/sh_log_repeat.c
===================================================================
--- trunk/src/sh_log_repeat.c	(revision 271)
+++ trunk/src/sh_log_repeat.c	(revision 272)
@@ -521,4 +521,5 @@
       char * tmpmsg;
       char * tmphost;
+      sh_string * alias;
 
       /* issue report             */
@@ -530,4 +531,12 @@
 		       FIL__, __LINE__, 0, MSG_LOGMON_BURST, 
 		       repeat, tmpmsg, tmphost);
+      alias = sh_log_lookup_alias(sh_repeat_queue);
+      if (alias)
+	{
+	  sh_error_mail (sh_string_str(alias), 
+			 sh_log_lookup_severity(sh_repeat_queue), 
+			 FIL__, __LINE__, 0, MSG_LOGMON_BURST, 
+			 repeat, tmpmsg, tmphost);
+	}
       SH_FREE(tmpmsg);
       SH_FREE(tmphost);
Index: trunk/src/sh_mail.c
===================================================================
--- trunk/src/sh_mail.c	(revision 271)
+++ trunk/src/sh_mail.c	(revision 272)
@@ -947,4 +947,5 @@
 
 static time_t time_wait = 300;
+static void report_smtp (char * reply);
 
 static FILE * sh_mail_start_conn (struct alias * ma_address, 
@@ -1113,12 +1114,14 @@
   if (0 != is_numeric(sh.host.name))
     {
-      TPT(( 0, FIL__, __LINE__, _("msg=<HELO [%s]>%c%c"), 
-	    sh.host.name, 13, 10));
+      sl_snprintf(error_msg, sizeof(error_msg), "HELO [%s]", 
+		  sh.host.name);
     }
   else
     {
-      TPT(( 0, FIL__, __LINE__, _("msg=<HELO %s>%c%c"), 
-	    sh.host.name, 13, 10));
-    }
+      sl_snprintf(error_msg, sizeof(error_msg), "HELO %s", 
+		  sh.host.name);
+    }
+  report_smtp(error_msg);
+
   if (0 != is_numeric(sh.host.name))
     fprintf(connFile, _("HELO [%s]%c%c"), sh.host.name, 13, 10);
@@ -1152,6 +1155,7 @@
     }
 
-  TPT(( 0, FIL__, __LINE__,  _("msg=<MAIL FROM:<%s>>%c%c"), 
-	this_address, 13, 10));
+  sl_snprintf(error_msg, sizeof(error_msg), "MAIL FROM:<%s>", 
+	      this_address);
+  report_smtp(error_msg);
 
   (void) fflush(connFile);
@@ -1175,6 +1179,7 @@
   if (aFlag == 0)
     {
-      TPT(( 0, FIL__, __LINE__,  _("msg=<RCPT TO:<%s>>%c%c"), 
-	    address, 13, 10)); 
+      sl_snprintf(error_msg, sizeof(error_msg), "RCPT TO:<%s>", 
+		  address);
+      report_smtp(error_msg);
 
       (void) fflush(connFile);
@@ -1210,6 +1215,7 @@
 	  ++address_num;
 
-	  TPT(( 0, FIL__, __LINE__,  _("msg=<RCPT TO:<%s>>%c%c"), 
-		sh_string_str(ma_address->recipient), 13, 10)); 
+	  sl_snprintf(error_msg, sizeof(error_msg), "RCPT TO:<%s>", 
+		      sh_string_str(ma_address->recipient));
+	  report_smtp(error_msg);
 	  
 	  (void) fflush(connFile);
@@ -1241,5 +1247,5 @@
   /* Send the message 
    */
-  TPT(( 0, FIL__, __LINE__,  _("msg=<DATA>%c%c"), 13, 10)); 
+  report_smtp(_("DATA"));
 
   (void) fflush(connFile);
@@ -1273,4 +1279,6 @@
   TPT(( 0, FIL__, __LINE__,  _("msg=<From: <%s>%c%cTo: <%s>%c%cDate: %s>%c%c"),
 	this_address, 13, 10, address, 13, 10, my_tbuf, 13, 10));
+
+  report_smtp(_("sending data.."));
 
   (void) fflush(connFile);
@@ -1299,9 +1307,9 @@
   time_wait = 300;
 
+  report_smtp(_("."));
+
   (void) fflush(connFile);
   fprintf(connFile, _("%c%c.%c%c"), 13, 10, 13, 10);   
   (void) fflush(connFile);
-
-  TPT(( 0, FIL__, __LINE__, _("msg=<message end written>\n")));
 
   if (0 != sh_mail_wait(250, fd))
@@ -1332,4 +1340,22 @@
  *
  */
+extern int flag_err_debug;
+
+static void report_smtp (char * reply)
+{
+  char * tmp;
+
+  if (flag_err_debug == SL_TRUE)
+    {
+      tmp = sh_util_safe_name_keepspace(reply);
+
+      sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN,
+		       tmp,
+		       _("report_smtp") );
+      SH_FREE(tmp);
+    }
+  return;
+}
+
 
 static int sh_mail_wait(int code, int ma_socket)
@@ -1339,5 +1365,7 @@
   char c;
 
-  char errmsg[128];
+  char errmsg[194];
+  char reply[128];
+  unsigned int  ireply = 0;
 
   enum { 
@@ -1357,8 +1385,19 @@
    */
 
-  rcode = 0;
-  state = WAIT_CODE_START;
+  rcode    = 0;
+  state    = WAIT_CODE_START;
+  reply[0] = '\0';
 
   while (sl_read_timeout_fd (ma_socket, &c, 1, time_wait, SL_FALSE) > 0) {
+
+    if (ireply < (sizeof(reply) - 1))
+      {
+	if (c != '\n' && c != '\r')
+	  {
+	    reply[ireply] = c;
+	    ++ireply;
+	    reply[ireply] = '\0';
+	  }
+      }
 
     g = (int) c;
@@ -1379,6 +1418,9 @@
       if (0 != isspace(g))
 	break;             /* Skip white space                    */
-      if (0 == isdigit(g))
-	return 0;          /* No leading number                   */
+      if (0 == isdigit(g)) 
+	{
+	  report_smtp(reply);
+	  SL_RETURN( 0, _("mail_wait")); /* No leading number     */
+	}
       rcode = g-(int)'0';  /* convert to number                   */
       state = WAIT_CODE;
@@ -1411,10 +1453,16 @@
       if (g != 1)
 	{
+	  char * tmp = sh_util_safe_name_keepspace(reply);
           sl_snprintf(errmsg, sizeof(errmsg),
-		      _("Bad response (%d), expected %d"), rcode, code);
+		      _("Bad response (%s), expected %d"), tmp, code);
+	  SH_FREE(tmp);
 
 	  sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_NET, 
 			  errmsg, _("sh_mail_wait"), 
 			  _("mail"), _("SMTP server"));
+	}
+      else
+	{
+	  report_smtp(reply);
 	}
       waited_time = time(NULL) - waited_time;
@@ -1438,4 +1486,5 @@
 
       TPT((0, FIL__, __LINE__, _("msg=<mail_wait: bad>\n"))); 
+      report_smtp(reply);
       SL_RETURN( 0, _("mail_wait")); 
       
@@ -1446,4 +1495,5 @@
 
   /* Failed, EOF or error on socket */
+  report_smtp(reply);
   SL_RETURN( 0, _("mail_wait")); 
 }
Index: trunk/src/sh_nmail.c
===================================================================
--- trunk/src/sh_nmail.c	(revision 271)
+++ trunk/src/sh_nmail.c	(revision 272)
@@ -65,5 +65,8 @@
 struct alias * all_recipients = NULL;
 
-int check_double (const char * str, struct alias * list)
+/* Check if addr is in list. If list is all_recipients,
+ * must iterate over ->all_next instead of ->next
+ */
+static int check_double (const char * str, struct alias * list, int isAll)
 {
   if (str && list)
@@ -73,7 +76,12 @@
       while (item)
 	{
+	  fprintf(stderr, "FIXME check %s %s\n", str, sh_string_str(item->recipient));
+
 	  if (0 == strcmp(sh_string_str(item->recipient), str))
 	    return -1;
-	  item = item->next;
+	  if (isAll)
+	    item = item->all_next;
+	  else
+	    item = item->next;
 	}
     }
@@ -81,4 +89,8 @@
 }
 
+/* Add recipient to 'list' AND to all_recipients. If
+ * it already is in all_recipients, mark it as an alias
+ * (isAlias = 1).
+ */
 struct alias * add_recipient_intern(const char * str, 
 				    struct alias * list)
@@ -93,10 +105,17 @@
       new->severity       = (-1);
       new->send_mail      = 0;
+      new->isAlias        = 0;
       new->recipient      = sh_string_new_from_lchar(str, strlen(str));
       list                = new;
 
       SH_MUTEX_LOCK_UNSAFE(mutex_listall);
+      fprintf(stderr, "FIXME intern %s\n", str);
+      if (0 == check_double(str, all_recipients, S_TRUE))
+	{
+	  new->isAlias    = 1;
+	}
       new->all_next       = all_recipients;
       all_recipients      = new;
+      fprintf(stderr, "FIXME intern end\n");
       SH_MUTEX_UNLOCK_UNSAFE(mutex_listall);
     }
@@ -116,9 +135,14 @@
 }
 
-/* Add a single recipient
+/* Add a single recipient. Must not be in in
+ * recipient_list already, and not in all_recipients.
  */
 int sh_nmail_add_recipient(const char * str)
 {
-  if (0 == check_double(str,  recipient_list))
+  /* return error if duplicate, or 
+   * already defined within an alias list.
+   */
+  if (0 == check_double(str,  recipient_list, S_FALSE) &&
+      0 == check_double(str,  all_recipients, S_TRUE))
     {
       recipient_list = add_recipient_intern(str, recipient_list);
@@ -133,5 +157,5 @@
 int sh_nmail_add_compiled_recipient(const char * str)
 {
-  if (0 == check_double(str,  compiled_recipient_list))
+  if (0 == check_double(str,  compiled_recipient_list, S_FALSE))
     {
       compiled_recipient_list = 
@@ -164,4 +188,6 @@
       if (strlen(new) > 0)
 	{
+	  /* strip trailing space
+	   */
 	  --q; while ((q != new) && *q == ' ') { *q = '\0'; --q; }
 	}
@@ -171,26 +197,49 @@
 	}
 
-      if (0 == check_double(new, alias_list))
-	{
+      if (0 == check_double(new, alias_list, S_FALSE))
+	{
+
+	  fprintf(stderr, "FIXME LIST %s\n", p);
 
 	  array = split_array_list(p, &nfields, lengths);
 
+	  fprintf(stderr, "FIXME LIST %d\n", nfields);
+
 	  if (array && nfields > 0)
 	    {
-	      struct alias * newalias  = SH_ALLOC(sizeof(struct alias));
-	      newalias->recipient_list = NULL;
-	      newalias->mail_filter    = NULL;
-	      newalias->mx_list        = NULL;
-	      newalias->severity       = (-1);
-	      /* This is the alias */
-	      newalias->recipient = sh_string_new_from_lchar(new, strlen(new));
-
-	      for (i = 0; i < nfields; ++i)
+	      struct alias * newalias = NULL;
+
+	      /* Enforce that all list members are defined already
+	       */
+	      int                nflag = 0;
+
+	      for (i = 0; i < nfields; ++i) {
+		if (0 == check_double(array[i],  all_recipients, S_TRUE))
+		  nflag = 1;
+	      }
+
+	      if (nflag == 0)
 		{
-		  if (lengths[i] > 0 && 
-		      0 == check_double(array[i], newalias->recipient_list))
+		  newalias                 = SH_ALLOC(sizeof(struct alias));
+		  newalias->recipient_list = NULL;
+		  newalias->mail_filter    = NULL;
+		  newalias->mx_list        = NULL;
+		  newalias->severity       = (-1);
+		  
+		  /* This is the alias */
+		  newalias->recipient = sh_string_new_from_lchar(new, strlen(new));
+		  
+		  for (i = 0; i < nfields; ++i)
 		    {
-		      newalias->recipient_list = 
-			add_recipient_intern(array[i],newalias->recipient_list);
+		      fprintf(stderr, "FIXME LIST(%d) %s\n", lengths[i], array[i]);
+		      
+		      if (lengths[i] > 0 && 
+			  0 == check_double(array[i], newalias->recipient_list, S_FALSE))
+			{
+			  fprintf(stderr, "FIXME add %s\n", array[i]);
+			  
+			  newalias->recipient_list = 
+			    add_recipient_intern(array[i], newalias->recipient_list);
+			}
 		    }
 		}
@@ -198,5 +247,5 @@
 	      SH_FREE(array);
 
-	      if (newalias->recipient_list == NULL)
+	      if (newalias && newalias->recipient_list == NULL)
 		{
 		  SH_FREE(newalias);
@@ -304,4 +353,10 @@
     }
 
+  if (alias)
+    {
+      fprintf(stderr, "FIXME %s, %s, %s\n", alias, 
+	      (rcv->mail_filter) ? "filtered" : "NULL", message);
+    }
+
   return 1;
 }
@@ -365,10 +420,18 @@
 	  /* Mark the entry
 	   */
-	  if (flagit)
-	    list->send_mail = 1;
 	  if (flag)
-	    list = list->all_next;
+	    {
+	      /* Don't mark aliases
+	       */
+	      if (flagit && list->isAlias == 0)
+		list->send_mail = 1;
+	      list = list->all_next;
+	    }
 	  else
-	    list = list->next;
+	    {
+	      if (flagit)
+		  list->send_mail = 1;
+	      list = list->next;
+	    }
 	  ++retval;
 	}
@@ -551,5 +614,8 @@
   reset_list(fifo_mail);
 
-  /* Compiled recipients
+  fprintf(stderr, "FIXME Compiled\n");
+
+  /* Compiled recipients. These share threshold and filter,
+   * hence only the first recipient needs to be tested.
    */
   list  = compiled_recipient_list;
@@ -558,5 +624,5 @@
     {
       msg   = tag_list(fifo_mail, sh_string_str(list->recipient),
-		       sh_nmail_valid_message_for_alias, list);
+		       sh_nmail_valid_message_for_alias, list, S_TRUE);
     }
 
@@ -585,7 +651,8 @@
     }
 
+  fprintf(stderr, "FIXME Aliases\n");
+
   /* Aliases
    */
-
   list  = alias_list;
 
@@ -601,5 +668,5 @@
       {
 	msg   = tag_list(fifo_mail, sh_string_str(list->recipient),
-			 sh_nmail_valid_message_for_alias, list);
+			 sh_nmail_valid_message_for_alias, list, S_FALSE);
 
 	if (msg)
@@ -624,4 +691,5 @@
 	    while (lnew)
 	      {
+		fprintf(stderr, "FIXME %s\n", sh_string_str(lnew->recipient));
 		lnew->send_mail = 1;
 		lnew= lnew->next;
@@ -659,4 +727,6 @@
 
 
+  fprintf(stderr, "FIXME Single\n");
+
   /* Single recipients
    */
@@ -673,5 +743,5 @@
       {
 	msg   = tag_list(fifo_mail, sh_string_str(list->recipient),
-		       sh_nmail_valid_message_for_alias, list);
+			 sh_nmail_valid_message_for_alias, list, S_TRUE);
 
 	if (msg)
Index: trunk/src/sh_readconf.c
===================================================================
--- trunk/src/sh_readconf.c	(revision 271)
+++ trunk/src/sh_readconf.c	(revision 272)
@@ -182,5 +182,5 @@
     ++p; while (isspace((int)*p)) ++p;
 
-    if (0 != strncmp(p, _("if "),   3)) {
+    if (0 != strncasecmp(p, _("if "),   3)) {
       cond_type = SH_RC_HOST; /* [!]$host */
     }
@@ -190,5 +190,5 @@
       p += 3; while (isspace((int)*p)) ++p; /* skip the 'if\s+' */
 
-      if (0 == strncmp(p, _("not "), 4))
+      if (0 == strncasecmp(p, _("not "), 4))
 	{
 	  p += 4; while (isspace((int)*p)) ++p;
@@ -201,21 +201,21 @@
 	}
   
-      if (0 == strncmp(p, _("file_exists "), 12))
+      if (0 == strncasecmp(p, _("file_exists "), 12))
 	{
 	  p += 12; cond_type = SH_RC_FILE;
 	}
-      else if (0 == strncmp(p, _("interface_exists "), 17))
+      else if (0 == strncasecmp(p, _("interface_exists "), 17))
 	{
 	  p += 17; cond_type = SH_RC_IFACE;
 	}
-      else if (0 == strncmp(p, _("hostname_matches "), 17))
+      else if (0 == strncasecmp(p, _("hostname_matches "), 17))
 	{
 	  p += 17; cond_type = SH_RC_HOST;
 	}
-      else if (0 == strncmp(p, _("system_matches "), 15))
+      else if (0 == strncasecmp(p, _("system_matches "), 15))
 	{
 	  p += 15; cond_type = SH_RC_SYSTEM;
 	}
-      else if (0 == strncmp(p, _("command_succeeds "), 17))
+      else if (0 == strncasecmp(p, _("command_succeeds "), 17))
 	{
 	  p += 17; cond_type = SH_RC_CMD;
@@ -289,6 +289,6 @@
       ++p; while (isspace((int)*p)) ++p;
       if ( 
-	  (0 == strncmp (p, _("end"), 3) && (p[3] == '\0' || isspace((int)p[3]))) ||
-	  (0 == strncmp (p, _("fi"),  2) && (p[2] == '\0' || isspace((int)p[2])))
+	  (0 == strncasecmp (p, _("end"), 3) && (p[3] == '\0' || isspace((int)p[3]))) ||
+	  (0 == strncasecmp (p, _("fi"),  2) && (p[2] == '\0' || isspace((int)p[2])))
 	   )
 	{
@@ -307,5 +307,5 @@
       char * p = str;
       ++p; while (isspace((int)*p)) ++p;
-      if ( 0 == strncmp (p, _("else"), 4) && (p[4] == '\0' || isspace((int)p[4])) )
+      if ( 0 == strncasecmp (p, _("else"), 4) && (p[4] == '\0' || isspace((int)p[4])) )
 	{
 	  return 1;
@@ -586,5 +586,5 @@
 	read_mode = SH_SECTION_NONE;
 
-	if (0 == sl_strncmp (line,  _("[EOF]"), 5)) {
+	if (0 == sl_strncasecmp (line,  _("[EOF]"), 5)) {
 	  goto nopel;
 	}
@@ -594,6 +594,6 @@
 	while (tab_ListSections[i].name != 0)
 	  {
-	    if (sl_strncmp (line, _(tab_ListSections[i].name), 
-			    sl_strlen(tab_ListSections[i].name)) == 0)
+	    if (sl_strncasecmp (line, _(tab_ListSections[i].name), 
+				sl_strlen(tab_ListSections[i].name)) == 0)
 	      { 
 		read_mode = tab_ListSections[i].type;
@@ -608,6 +608,6 @@
 	    for (modnum = 0; modList[modnum].name != NULL; ++modnum) 
 	      {
-		if (0 == sl_strncmp (line,  _(modList[modnum].conf_section),
-				     sl_strlen(modList[modnum].conf_section)) )
+		if (0 == sl_strncasecmp (line, _(modList[modnum].conf_section),
+					 sl_strlen(modList[modnum].conf_section)) )
 		  read_mode = SH_SECTION_OTHER;
 	      }
@@ -626,7 +626,7 @@
       {
 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
-	if (line[0] == '!' && 0 == sl_strcmp(&(line[2]), _("SCHEDULE_TWO")))
+	if (line[0] == '!' && 0 == sl_strcasecmp(&(line[2]), _("SCHEDULE_TWO")))
 	  set_dirList(1);
-	else if (0 == sl_strcmp(&(line[1]), _("SCHEDULE_TWO")))
+	else if (0 == sl_strcasecmp(&(line[1]), _("SCHEDULE_TWO")))
 	  set_dirList(2);
 #else
Index: trunk/src/sh_socket.c
===================================================================
--- trunk/src/sh_socket.c	(revision 271)
+++ trunk/src/sh_socket.c	(revision 272)
@@ -209,5 +209,5 @@
 static void sh_socket_add2list (struct socket_cmd * in);
 
-void sh_socket_probe4reload (void)
+static void sh_socket_probe4reload (void)
 {
   struct reload_cmd  * new;
Index: trunk/src/slib.c
===================================================================
--- trunk/src/slib.c	(revision 271)
+++ trunk/src/slib.c	(revision 272)
@@ -1080,4 +1080,22 @@
   if (a != NULL && b != NULL)
     return (strncmp(a, b, n));
+  else if (a == NULL && b != NULL)
+    return (-1);
+  else if (a != NULL && b == NULL)
+    return (1);
+  else
+    return (-7); /* default to not equal */
+}
+
+int sl_strncasecmp(const char * a, const char * b, size_t n)
+{
+#ifdef SL_FAIL_ON_ERROR
+  SL_REQUIRE (a != NULL, _("a != NULL"));
+  SL_REQUIRE (b != NULL, _("b != NULL"));
+  SL_REQUIRE (n > 0, _("n > 0"));
+#endif
+
+  if (a != NULL && b != NULL)
+    return (strncasecmp(a, b, n));
   else if (a == NULL && b != NULL)
     return (-1);
