--- /jlkqms/temp/dspam-3.10.1/src/dspam.c	2011-07-31 05:54:31.000000000 +1000
+++ /jlkqms/temp/dspam-3.10.1-jlk/src/dspam.c	2011-10-28 14:38:13.000000000 +1000
@@ -1551,6 +1551,9 @@
     return EUNKNOWN;
   }
 
+  snprintf(buf, sizeof(buf), "From DSPAM %s", ctime(&now));
+  buffer_cat(b, buf);
+
   strftime(buf,sizeof(buf), "Date: %a, %d %b %Y %H:%M:%S %z\n",
      localtime(&now));
   buffer_cat(b, buf);
@@ -1568,8 +1571,13 @@
     buffer_cat(b, s);
   }
   fclose(f);
-  ret = deliver_message(ATX, b->data, mailer_args, username,
-                        stdout, DSR_ISINNOCENT);
+  ret = deliver_message(ATX, b->data,
+			(ATX->flags & DAF_STDOUT) ? NULL : ATX->mailer_args,
+                        username, 
+                        ATX->sockfd ? ATX->sockfd : stdout,
+                        DSR_ISINNOCENT);
+  if (ATX->sockfd && ATX->flags & DAF_STDOUT)
+    ATX->sockfd_output = 1;			
 
   buffer_destroy(b);
 
@@ -4354,12 +4362,13 @@
     if (file == NULL) {
       LOGDEBUG("sending firstrun.txt to %s (%s): %s",
                CTX->username, filename, strerror(errno));
-      send_notice(ATX, "firstrun.txt", ATX->mailer_args, CTX->username);
-      _ds_prepare_path_for(filename);
-      file = fopen(filename, "w");
-      if (file) {
-        fprintf(file, "%ld\n", (long) time(NULL));
-        fclose(file);
+      if (!send_notice(ATX, "firstrun.txt", ATX->mailer_args, CTX->username)) {
+        _ds_prepare_path_for(filename);
+        file = fopen(filename, "w");
+        if (file) {
+          fprintf(file, "%ld\n", (long) time(NULL));
+          fclose(file);
+	}
       }
     } else {
       fclose(file);
@@ -4381,12 +4390,13 @@
     if (file == NULL) {
       LOGDEBUG("sending firstspam.txt to %s (%s): %s",
                CTX->username, filename, strerror(errno));
-      send_notice(ATX, "firstspam.txt", ATX->mailer_args, CTX->username);
-      _ds_prepare_path_for(filename);
-      file = fopen(filename, "w");
-      if (file) {
-        fprintf(file, "%ld\n", (long) time(NULL));
-        fclose(file);
+      if (!send_notice(ATX, "firstspam.txt", ATX->mailer_args, CTX->username)) {
+        _ds_prepare_path_for(filename);
+        file = fopen(filename, "w");
+        if (file) {
+          fprintf(file, "%ld\n", (long) time(NULL));
+          fclose(file);
+        }
       }
     } else {
       fclose(file);
@@ -4418,14 +4428,13 @@
                        LOOKUP(ATX->PTX, CTX->username), "mboxwarn");
       if (stat(qfile, &s)) {
         FILE *f;
-
-        _ds_prepare_path_for(qfile);
-        f = fopen(qfile, "w");
-        if (f != NULL) {
-          fprintf(f, "%ld", (long) time(NULL));
-          fclose(f);
-
-          send_notice(ATX, "quarantinefull.txt", ATX->mailer_args, CTX->username);
+	if (!send_notice(ATX, "quarantinefull.txt", ATX->mailer_args, CTX->username)) {
+          _ds_prepare_path_for(qfile);
+          f = fopen(qfile, "w");
+          if (f != NULL) {
+            fprintf(f, "%ld", (long) time(NULL));
+            fclose(f);
+	  }
         }
       }
     }
