diff --new-file -u -r nullmailer-1.00/lib/defines.h nullmailer-lq-1.00/lib/defines.h
--- nullmailer-1.00/lib/defines.h	2002-12-16 15:24:27.000000000 -0500
+++ nullmailer-lq-1.00/lib/defines.h	2005-03-26 22:05:03.000000000 -0500
@@ -9,5 +9,6 @@
 extern const char* PROTOCOL_DIR;
 extern const char* BIN_DIR;
 extern const char* SBIN_DIR;
+extern const char* ADMINFILE;
 
 #endif /* NULLMAILER__DEFINES__H__ */
diff --new-file -u -r nullmailer-1.00/lib/make_defines.sh nullmailer-lq-1.00/lib/make_defines.sh
--- nullmailer-1.00/lib/make_defines.sh	2002-12-16 15:24:27.000000000 -0500
+++ nullmailer-lq-1.00/lib/make_defines.sh	2005-03-26 22:05:39.000000000 -0500
@@ -7,3 +7,4 @@
 echo "const char* PROTOCOL_DIR=\"$3/\";"		>>defines.cc
 echo "const char* BIN_DIR=\"$4/\";"			>>defines.cc
 echo "const char* SBIN_DIR=\"$5/\";"			>>defines.cc
+echo "const char* ADMINFILE=\"/home/nullmail/mail/inbox\";"         >>defines.cc
diff --new-file -u -r nullmailer-1.00/Makefile.in nullmailer-lq-1.00/Makefile.in
--- nullmailer-1.00/Makefile.in	2005-02-28 12:39:50.000000000 -0500
+++ nullmailer-lq-1.00/Makefile.in	2005-03-26 22:00:25.000000000 -0500
@@ -586,7 +586,9 @@
 install-root:
 	chown nullmail $(DESTDIR)$(localstatedir)/*
 	chown nullmail $(DESTDIR)$(sbindir)/nullmailer-queue
+	chown nullmail $(DESTDIR)$(sbindir)/nullmailer-localqueue
 	chmod u+s $(DESTDIR)$(sbindir)/nullmailer-queue
+	chmod u+s $(DESTDIR)$(sbindir)/nullmailer-localqueue
 	chown nullmail $(DESTDIR)$(bindir)/mailq
 	chmod u+s $(DESTDIR)$(bindir)/mailq
 
diff --new-file -u -r nullmailer-1.00/nullmailer-1.00.spec nullmailer-lq-1.00/nullmailer-1.00.spec
--- nullmailer-1.00/nullmailer-1.00.spec	2005-02-28 13:10:43.000000000 -0500
+++ nullmailer-lq-1.00/nullmailer-1.00.spec	1969-12-31 19:00:00.000000000 -0500
@@ -1,93 +0,0 @@
-Name: nullmailer
-Summary: Simple relay-only mail transport agent
-Version: 1.00
-Release: 1
-Copyright: GPL
-Group: Networking/Daemons
-Source: http://em.ca/~bruceg/nullmailer/archive/%{version}/nullmailer-%{version}.tar.gz
-BuildRoot: /tmp/nullmailer-root
-URL: http://em.ca/~bruceg/nullmailer/
-Packager: Bruce Guenter <bruceg@em.ca>
-Provides: smtpdaemon
-Conflicts: sendmail
-Conflicts: qmail
-Requires: supervise-scripts >= 3.2
-PreReq: shadow-utils
-
-%description
-Nullmailer is a mail transport agent designed to only relay all its
-messages through a fixed set of "upstream" hosts.  It is also designed
-to be secure.
-
-%prep
-%setup
-
-%build
-CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
-./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
-
-make
-
-%install
-rm -fr $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT/etc
-mkdir -p $RPM_BUILD_ROOT/usr/lib
-mkdir -p $RPM_BUILD_ROOT/var/nullmailer/service/log
-mkdir -p $RPM_BUILD_ROOT/var/log/nullmailer
-
-make DESTDIR=$RPM_BUILD_ROOT install-strip
-ln -s ../sbin/sendmail $RPM_BUILD_ROOT/usr/lib/sendmail
-install scripts/nullmailer.run $RPM_BUILD_ROOT/var/nullmailer/service/run
-install scripts/nullmailer-log.run $RPM_BUILD_ROOT/var/nullmailer/service/log/run
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%pre
-PATH="/sbin:/usr/sbin:$PATH" export PATH
-if [ "$1" = 1 ]; then
-	# pre-install instructions
-	grep ^nullmail: /etc/group >/dev/null || groupadd -r nullmail
-	grep ^nullmail: /etc/passwd >/dev/null || useradd -d /var/lock/svc/nullmailer -g nullmail -M -r -s /bin/true nullmail
-fi
-
-%post
-if ! [ -L /service/nullmailer ]; then
-	svc-add /var/nullmailer/service nullmailer
-fi
-if ! [ -s /etc/nullmailer/me ]; then
-	/bin/hostname --fqdn >/etc/nullmailer/me
-fi
-if ! [ -s /etc/nullmailer/defaultdomain ]; then
-	/bin/hostname --domain >/etc/nullmailer/defaultdomain
-fi
-
-%preun
-if [ "$1" = 0 ]; then
-	svc-remove nullmailer
-fi
-
-%postun
-if [ "$1" = 0 ]; then
-	# post-erase instructions
-	/usr/sbin/userdel nullmail
-	/usr/sbin/groupdel nullmail
-fi
-
-%files
-%defattr(-,nullmail,nullmail)
-%doc AUTHORS BUGS ChangeLog COPYING INSTALL NEWS README TODO YEAR2000
-%dir /etc/nullmailer
-%attr(04711,nullmail,nullmail) /usr/bin/mailq
-/usr/bin/nullmailer-inject
-/usr/lib/sendmail
-%dir /usr/libexec/nullmailer
-/usr/libexec/nullmailer/*
-/usr/man/man1/*
-/usr/man/man7/*
-/usr/man/man8/*
-%attr(04711,nullmail,nullmail) /usr/sbin/nullmailer-queue
-/usr/sbin/nullmailer-send
-/usr/sbin/sendmail
-%dir /var/log/nullmailer
-/var/nullmailer
diff --new-file -u -r nullmailer-1.00/nullmailer-lq-1.00.spec nullmailer-lq-1.00/nullmailer-lq-1.00.spec
--- nullmailer-1.00/nullmailer-lq-1.00.spec	1969-12-31 19:00:00.000000000 -0500
+++ nullmailer-lq-1.00/nullmailer-lq-1.00.spec	2005-03-26 23:11:19.016400424 -0500
@@ -0,0 +1,96 @@
+Name: nullmailer-lq
+Summary: Simple relay-only mail transport agent
+Version: 1.00
+Release: 1
+Copyright: GPL
+Group: Networking/Daemons
+Source: http://www.basher584.org/basher584/nullmail-lq/nullmailer-lq-1.00.tar.gz
+BuildRoot: /tmp/nullmailer-root
+URL: http://www.basher584.org/basher584/nullmail-lq/
+Packager: Basher584
+Provides: smtpdaemon
+Conflicts: sendmail
+Conflicts: qmail
+#Requires: supervise-scripts >= 3.2
+PreReq: shadow-utils
+
+%description
+Nullmailer-localqueue is a patched version of Bruce Guenter's nullmailer
+program that delivers all local mail to a local mbox.
+Nullmailer is a mail transport agent designed to only relay all
+its messages through a fixed set of "upstream" hosts.  It is also designed
+to be secure.
+
+%prep
+%setup
+
+%build
+CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" \
+./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
+
+make
+
+%install
+rm -fr $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/etc
+mkdir -p $RPM_BUILD_ROOT/usr/lib
+mkdir -p $RPM_BUILD_ROOT/var/nullmailer/service/log
+mkdir -p $RPM_BUILD_ROOT/var/log/nullmailer
+
+make DESTDIR=$RPM_BUILD_ROOT install-strip
+ln -s ../sbin/sendmail $RPM_BUILD_ROOT/usr/lib/sendmail
+install scripts/nullmailer.run $RPM_BUILD_ROOT/var/nullmailer/service/run
+install scripts/nullmailer-log.run $RPM_BUILD_ROOT/var/nullmailer/service/log/run
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%pre
+PATH="/sbin:/usr/sbin:$PATH" export PATH
+if [ "$1" = 1 ]; then
+	# pre-install instructions
+	grep ^nullmail: /etc/group >/dev/null || groupadd -r nullmail
+	grep ^nullmail: /etc/passwd >/dev/null || useradd -g nullmail -r -s /sbin/nologin nullmail
+fi
+
+%post
+#if ! [ -L /service/nullmailer ]; then
+#	svc-add /var/nullmailer/service nullmailer
+#fi
+if ! [ -s /etc/nullmailer/me ]; then
+	/bin/hostname --fqdn >/etc/nullmailer/me
+fi
+if ! [ -s /etc/nullmailer/defaultdomain ]; then
+	/bin/hostname --domain >/etc/nullmailer/defaultdomain
+fi
+
+%preun
+#if [ "$1" = 0 ]; then
+#	svc-remove nullmailer
+#fi
+
+%postun
+if [ "$1" = 0 ]; then
+	# post-erase instructions
+	/usr/sbin/userdel nullmail
+	/usr/sbin/groupdel nullmail
+fi
+
+%files
+%defattr(-,nullmail,nullmail)
+%doc AUTHORS BUGS ChangeLog COPYING INSTALL NEWS README TODO YEAR2000
+%dir /etc/nullmailer
+%attr(04711,nullmail,nullmail) /usr/bin/mailq
+/usr/bin/nullmailer-inject
+/usr/lib/sendmail
+%dir /usr/libexec/nullmailer
+/usr/libexec/nullmailer/*
+/usr/man/man1/*
+/usr/man/man7/*
+/usr/man/man8/*
+%attr(04711,nullmail,nullmail) /usr/sbin/nullmailer-queue
+%attr(04711,nullmail,nullmail) /usr/sbin/nullmailer-localqueue
+/usr/sbin/nullmailer-send
+/usr/sbin/sendmail
+%dir /var/log/nullmailer
+/var/nullmailer
diff --new-file -u -r nullmailer-1.00/README.localqueue nullmailer-lq-1.00/README.localqueue
--- nullmailer-1.00/README.localqueue	1969-12-31 19:00:00.000000000 -0500
+++ nullmailer-lq-1.00/README.localqueue	2005-03-26 22:04:15.000000000 -0500
@@ -0,0 +1,28 @@
+nullmailer-lq
+Simple relay-only mail transport agent w/ localqueue support
+http://www.basher584.org/basher584/nullmail-lq/
+Version 1.00-lq
+2005-03-26
+
+This is a patched version of nullmailer to support delivery of local mail
+to an admin mailbox in mbox format.
+
+Nullmailer is a sendmail/qmail/etc replacement MTA for hosts which
+relay to a fixed set of smart relays.  It is designed to be simple to
+configure, secure, and easily extend-able.
+
+Please see the README file for more information about the nullmailer
+program.
+
+See website for specific changes and more inforamtion:
+http://www.basher584.org/basher584/nullmail-lq/
+
+src/localqueue.cc is Copyright(C) 2005 Benic Systems, and may be copied 
+according to the the GNU GENERAL PUBLIC LICENSE (GPL) Version 2 or a later 
+version.  A copy of this license is included with this package.  This 
+package comes with no warranty of any kind.
+
+queue.cc is from the nullmailer package and Copyright(C) 2005 Bruce 
+Guenter
+
+See the README file for the rest of the Copyright information.
diff --new-file -u -r nullmailer-1.00/src/inject.cc nullmailer-lq-1.00/src/inject.cc
--- nullmailer-1.00/src/inject.cc	2005-02-25 19:04:04.000000000 -0500
+++ nullmailer-lq-1.00/src/inject.cc	2005-03-26 22:34:40.000000000 -0500
@@ -403,8 +403,8 @@
       headers.append("Resent-To: " + make_recipient_list());
     }
   }
-  if(!header_has_to && !header_has_cc)
-    headers.append("Cc: recipient list not shown: ;");
+  //if(!header_has_to && !header_has_cc)
+  //  headers.append("Cc: recipient list not shown: ;");
   return true;
 }
 
@@ -412,7 +412,36 @@
 // Message sending
 ///////////////////////////////////////////////////////////////////////////////
 static fdobuf* nqpipe = 0;
+static fdobuf* adminfile = 0;  //TODO give adminfile a defualt
 static pid_t pid = 0;
+static pid_t adminpid = 0;
+static bool adminmsg = false;
+static bool adminonly = true;
+static int affd;
+bool admin_addr(mystring addr);
+
+void admin_only() {
+  for(slist::iter iter(recipients); iter; iter++) {
+   //TODO add config option for sending to local spool like doremap
+      if(!admin_addr(*iter)) {
+         adminonly=false;
+      } else {
+         adminmsg = true;
+      }
+   }
+}
+
+bool admin_addr(mystring addr) {
+   int i = addr.find_last('@');
+   if(i < 0)
+      return true;
+   mystring hostname = addr.right(i+1);
+   if(hostname == defaulthost || hostname == "localhost")
+      return true;
+   else
+      return false;
+}
+
 
 void exec_queue()
 {
@@ -428,74 +457,179 @@
   exit(1);
 }
 
+void exec_localqueue()
+ {
+  if(chdir(SBIN_DIR) == -1) {
+    fout << "nullmailer-inject: Could not change directory to " << SBIN_DIR
+    << ": " << strerror(errno) << endl;
+    exit(1);
+  }
+  else
+    execl("nullmailer-localqueue", "nullmailer-localqueue", 0);
+  fout << "nullmailer-inject: Could not exec nullmailer-localqueue: "
+       << strerror(errno) << endl;
+  exit(1);
+}
+
 bool start_queue()
 {
-  int pipe1[2];
-  if(pipe(pipe1) == -1)
-    fail_sys("Could not create pipe to nullmailer-queue");
-  fout.flush();
-  pid = fork();
-  if(pid == -1)
-    fail_sys("Could not fork");
-  if(pid == 0) {
-    close(pipe1[1]);
-    close(0);
-    dup2(pipe1[0], 0);
-    exec_queue();
-  }
-  else {
-    close(pipe1[0]);
-    nqpipe = new fdobuf(pipe1[1], true);
+  if(!adminonly) {
+    int pipe1[2];
+    if(pipe(pipe1) == -1)
+      fail_sys("Could not create pipe to nullmailer-queue");
+    fout.flush();
+    pid = fork();
+    if(pid == -1)
+      fail_sys("Could not fork");
+    if(pid == 0) {
+      close(pipe1[1]);
+      close(0);
+      dup2(pipe1[0], 0);
+      exec_queue();
+    }
+    else {
+      close(pipe1[0]);
+      nqpipe = new fdobuf(pipe1[1], true);
+    }
   }
+  if(adminmsg) {
+     int pipe2[2];
+     if(pipe(pipe2) == -1)
+         fail_sys("Could not create pipe to nullmailer-localqueue");
+     fout.flush();
+     adminpid = fork();
+     if(adminpid == -1)
+        fail_sys("Could not fork");
+     if(adminpid == 0) {
+        close(pipe2[1]);
+        close(0);
+        dup2(pipe2[0], 0);
+        exec_localqueue();
+     }
+     else {
+        close(pipe2[0]);
+        adminfile = new fdobuf(pipe2[1],true);
+      }
+   }
   return true;
 }
 
 bool send_env()
 {
-  if(!(*nqpipe << sender << "\n"))
-    fail("Error sending sender to nullmailer-queue.");
-  for(slist::iter iter(recipients); iter; iter++)
-    if(!(*nqpipe << *iter << "\n"))
-      fail("Error sending recipients to nullmailer-queue.");
-  if(!(*nqpipe << endl))
-    fail("Error sending recipients to nullmailer-queue.");
+   if(adminmsg) {
+      if(!(*adminfile << sender << "\n"))
+         fail("Error sending sender to adminfile.");
+   }
+   if(!adminonly) {
+      if(!(*nqpipe << sender << "\n"))
+         fail("Error sending sender to nullmailer-queue.");
+   }
+   if(!adminonly) {
+      for(slist::iter iter(recipients); iter; iter++) {
+         if(!(admin_addr(*iter))) {
+            if(!(*nqpipe << *iter << "\n"))
+               fail("Error sending recipients to nullmailer-queue.");
+        }
+      }
+      if(!(*nqpipe << endl))
+         fail("Error sending recipients to nullmailer-queue.");
+   }
   return true;
 }
 
 bool send_header()
 {
-  for(slist::iter iter(headers); iter; iter++)
-    if(!(*nqpipe << *iter << "\n"))
-      fail("Error sending header to nullmailer-queue.");
-  if(!(*nqpipe << endl))
-    fail("Error sending header to nullmailer-queue.");
+   for(slist::iter iter(headers); iter; iter++) {
+      if(adminmsg) {
+         if(!(*adminfile<< *iter << "\n"))
+            fail("Error sending header to adminfile.");
+      }
+      if(!adminonly) {
+         if(!(*nqpipe << *iter << "\n"))
+            fail("Error sending header to nullmailer-queue.");
+      }
+   }
+   if(adminmsg)
+      if(!(*adminfile << "\n"))
+         fail("Error sending header endl to adminfile.");
+   if(!adminonly)
+      if(!(*nqpipe << endl))
+         fail("Error sending header endl to nullmailer-queue.");
   return true;
 }
 
 bool send_body()
 {
-  if(!(*nqpipe << cur_line) ||
-     !fdbuf_copy(fin, *nqpipe))
-    fail("Error sending message body to nullmailer-queue.");
+   if(adminonly) {
+      if(!(*adminfile << cur_line) ||
+          !fdbuf_copy(fin, *adminfile))
+         fail("Error sending message body to adminfile.");
+      if(!(*adminfile << "\n"))
+         fail("Error sending message body to adminfile.");
+      if(!(adminfile->flush()))
+         fail("Error sending message body to adminfile.");
+   } else if (!adminmsg) {
+      if(!(*nqpipe << cur_line) ||
+          !fdbuf_copy(fin, *nqpipe))
+         fail("Error sending message body to nullmailer-queue.");
+   } else {
+      if(!(*nqpipe << cur_line ))
+         fail("Error sending message body to nullmailer-queue.");
+      if(!(*adminfile << cur_line ))
+         fail("Error sending message body to adminfile.");
+     while(fin.getline(cur_line)) {
+         if(!(*nqpipe << cur_line << "\n"))
+            fail("Error sending message body to nullmailer-queue.");
+         if(!(*adminfile << cur_line << "\n"))
+            fail("Error sending message body to adminfile.");
+      }
+      if(!(nqpipe->flush())) {
+         fail("Error sending message body to nullmailer-queue.");
+      }
+      if(!(*adminfile << "\n"))
+         fail("Error sending message body to adminfile.");
+      if(!(adminfile->flush())) {
+         fail("Error sending message body to adminfile.");
+      }
+   }
   return true;
 }
 
 bool wait_queue()
 {
-  if(!nqpipe->close())
-    fail("Error closing pipe to nullmailer-queue.");
-  int status;
-  if(waitpid(pid, &status, 0) == -1)
-    fail("Error catching the return value from nullmailer-queue.");
-  if(WIFEXITED(status)) {
-    status = WEXITSTATUS(status);
-    if(status)
-      fail("nullmailer-queue failed.");
-    else
-      return true;
-  }
-  else
-    fail("nullmailer-queue crashed or was killed.");
+   if(adminmsg) {
+      if(!adminfile->close())
+         fail("Error closing pipe to nullmailer-localqueue.");
+      int status;
+      if(waitpid(adminpid, &status, 0) == -1)
+         fail("Error catching the return value from nullmailer-localqueue.");
+      if(WIFEXITED(status)) {
+         status = WEXITSTATUS(status);
+         if(status)
+            fail("nullmailer-localqueue failed.");
+         else
+            return true;
+      }
+      else
+         fail("nullmailer-localqueue crashed or was killed.");
+   }
+  if(!adminonly) {
+      if(!nqpipe->close())
+         fail("Error closing pipe to nullmailer-queue.");
+      int status;
+      if(waitpid(pid, &status, 0) == -1)
+         fail("Error catching the return value from nullmailer-queue.");
+      if(WIFEXITED(status)) {
+         status = WEXITSTATUS(status);
+         if(status)
+            fail("nullmailer-queue failed.");
+         else
+            return true;
+      }
+      else
+         fail("nullmailer-queue crashed or was killed.");
+   }
+   return true;
 }
 
 bool send_message()
@@ -508,10 +642,12 @@
     send_body();
     return true;
   }
-  else
-    return start_queue() &&
-      send_env() && send_header() && send_body() &&
-      wait_queue();
+  else {
+    admin_only();
+     return start_queue() &&
+       send_env() && send_header() && send_body() &&
+       wait_queue();
+  }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --new-file -u -r nullmailer-1.00/src/localqueue.cc nullmailer-lq-1.00/src/localqueue.cc
--- nullmailer-1.00/src/localqueue.cc	1969-12-31 19:00:00.000000000 -0500
+++ nullmailer-lq-1.00/src/localqueue.cc	2005-03-26 22:58:19.000000000 -0500
@@ -0,0 +1,185 @@
+// nullmailer -- a simple relay-only MTA
+// Copyright (C) 2005 Benic Systems <benic@benicsystems.com>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+// See http://www.basher584.org/basher584/nullmail-lq/ for more details
+
+#include "config.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h>
+#include <unistd.h>
+#include "itoa.h"
+#include "defines.h"
+#include "mystring/mystring.h"
+#include "fdbuf/fdbuf.h"
+#include "configio.h"
+#include "canonicalize.h"
+#include "hostname.h"
+#include <iostream.h>
+
+extern "C" int lockf(int fd, int cmd, off_t len);
+extern "C" off_t lseek(int fildes, off_t offset, int whence);
+
+#define fail(MSG) do{ fout << "nullmailer-localqueue: " << MSG << endl; return false; }while(0)
+
+pid_t pid = getpid();
+uid_t uid = getuid();
+time_t timesecs = time(0);
+mystring adminaddr;
+bool remapadmin = false;
+
+bool is_dir(const char* path)
+{
+  struct stat buf;
+  return !stat(path, &buf) && S_ISDIR(buf.st_mode);
+}
+
+bool is_exist(const char* path)
+{
+  struct stat buf;
+  return !stat(path, &buf);
+}
+
+int fsyncdir(const char* path)
+{
+  int fd = open(path, O_RDONLY);
+  if(fd == -1)
+    return 0;
+  int result = fsync(fd);
+  if(result == -1 && errno != EIO)
+    result = 0;
+  close(fd);
+  return result;
+}
+
+void trigger()
+{
+  int fd = open(QUEUE_TRIGGER, O_WRONLY|O_NONBLOCK, 0666);
+  if(fd == -1)
+    return;
+  char x = 0;
+  write(fd, &x, 1);
+  close(fd);
+}
+
+bool validate_addr(mystring& addr, bool doremap)
+{
+  int i = addr.find_last('@');
+  if(i < 0)
+    return false;
+  mystring hostname = addr.right(i+1);
+  if(doremap && remapadmin) {
+    if(hostname == me || hostname == "localhost")
+      addr = adminaddr;
+  }
+  else if(hostname.find_first('.') < 0)
+    return false;
+  return true;
+}
+
+bool copyenv(fdobuf& out)
+{
+  mystring str;
+
+  if(!fin.getline(str) || !str)
+    fail("Could not read envelope sender.");
+  if(!validate_addr(str, false))
+    fail("Envelope sender address is invalid.");
+  char buf[100];
+  if(!strftime(buf, 100, " %a %b %d %H:%M:%S -0000 %Y", gmtime(&timesecs)))
+    fail("Error generating a date string.");
+  str+= buf; 
+  if(!(out << "From " << str << endl))
+    fail("Could not write envelope sender.");
+  return true;
+}
+
+bool makereceived(fdobuf& out)
+{
+  mystring line("Received: (nullmailer pid ");
+  line += itoa(pid);
+  line += " invoked by uid ";
+  line += itoa(uid);
+  line += ");\n\t";
+  char buf[100];
+  if(!strftime(buf, 100, "%a, %d %b %Y %H:%M:%S -0000\n", gmtime(&timesecs)))
+    fail("Error generating a date string.");
+  line += buf;
+  if(!(out << line))
+    fail("Could not write received line to message.");
+  return true;
+}
+
+bool dump(int fd)
+{
+  fdobuf out(fd);
+  if(!copyenv(out))
+    return false;
+  if(!makereceived(out))
+    return false;
+  if(!fdbuf_copy(fin, out))
+    fail("Error copying the message to the queue file.");
+  if(!out.flush())
+    fail("Error flushing the output file.");
+  return true;
+}
+
+bool deliver()
+{
+  int out = open(ADMINFILE, O_CREAT|O_WRONLY|O_APPEND, 0666);
+  if(out < 0)
+    fail("Could not open admin spool file for writing");
+  off_t pos=0;
+  if ((pos = lseek(out,0,SEEK_CUR))<0)
+		fail("Could not get current seek position");
+	while(lockf(out,F_TEST,pos)==-1) {
+		fout.flush();
+		sleep(1);
+	}
+  if(lockf(out,F_LOCK,pos)!=0)
+		fail("Could not lock file.");
+  if(!dump(out)) {
+		if(lockf(out,F_ULOCK,pos)!=0)
+			fail("Error unlocking file.");
+		if(close(out)!=0)
+			fail("Error closing the output file.");
+    unlink(ADMINFILE);
+    return false;
+  }
+	if(lockf(out,F_ULOCK,pos)!=0)
+		fail("Error unlocking file.");
+  if(close(out)!=0)
+    fail("Error closing the output file.");
+  return true;
+}
+
+int main(int, char*[])
+{
+  if(config_read("adminaddr", adminaddr) && !!adminaddr) {
+    remapadmin = true;
+	 read_hostnames();
+  }
+  
+  if(!deliver())
+    return 1;
+  return 0;
+}
diff --new-file -u -r nullmailer-1.00/src/Makefile.in nullmailer-lq-1.00/src/Makefile.in
--- nullmailer-1.00/src/Makefile.in	2005-02-28 12:39:50.000000000 -0500
+++ nullmailer-lq-1.00/src/Makefile.in	2005-03-26 22:51:30.000000000 -0500
@@ -38,7 +38,8 @@
 POST_UNINSTALL = :
 bin_PROGRAMS = mailq$(EXEEXT) nullmailer-inject$(EXEEXT)
 sbin_PROGRAMS = nullmailer-queue$(EXEEXT) nullmailer-send$(EXEEXT) \
-	sendmail$(EXEEXT)
+	sendmail$(EXEEXT) \
+	nullmailer-localqueue$(EXEEXT)
 subdir = src
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -63,6 +64,9 @@
 am_nullmailer_queue_OBJECTS = queue.$(OBJEXT)
 nullmailer_queue_OBJECTS = $(am_nullmailer_queue_OBJECTS)
 nullmailer_queue_DEPENDENCIES = ../lib/libnullmailer.a
+am_nullmailer_localqueue_OBJECTS = localqueue.$(OBJEXT)
+nullmailer_localqueue_OBJECTS = $(am_nullmailer_localqueue_OBJECTS)
+nullmailer_localqueue_DEPENDENCIES = ../lib/libnullmailer.a
 am_nullmailer_send_OBJECTS = send.$(OBJEXT)
 nullmailer_send_OBJECTS = $(am_nullmailer_send_OBJECTS)
 nullmailer_send_DEPENDENCIES = ../lib/libnullmailer.a
@@ -79,10 +83,10 @@
 	-o $@
 SOURCES = $(mailq_SOURCES) $(nullmailer_inject_SOURCES) \
 	$(nullmailer_queue_SOURCES) $(nullmailer_send_SOURCES) \
-	$(sendmail_SOURCES)
+	$(sendmail_SOURCES) $(nullmailer_localqueue_SOURCES)
 DIST_SOURCES = $(mailq_SOURCES) $(nullmailer_inject_SOURCES) \
 	$(nullmailer_queue_SOURCES) $(nullmailer_send_SOURCES) \
-	$(sendmail_SOURCES)
+	$(sendmail_SOURCES) $(nullmailer_localqueue_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -178,6 +182,8 @@
 nullmailer_inject_LDADD = ../lib/cli++/libcli++.a ../lib/libnullmailer.a
 nullmailer_queue_SOURCES = queue.cc
 nullmailer_queue_LDADD = ../lib/libnullmailer.a
+nullmailer_localqueue_SOURCES = localqueue.cc
+nullmailer_localqueue_LDADD = ../lib/libnullmailer.a
 nullmailer_send_SOURCES = send.cc
 nullmailer_send_LDADD = ../lib/libnullmailer.a
 sendmail_SOURCES = sendmail.cc
@@ -270,6 +276,9 @@
 nullmailer-queue$(EXEEXT): $(nullmailer_queue_OBJECTS) $(nullmailer_queue_DEPENDENCIES) 
 	@rm -f nullmailer-queue$(EXEEXT)
 	$(CXXLINK) $(nullmailer_queue_LDFLAGS) $(nullmailer_queue_OBJECTS) $(nullmailer_queue_LDADD) $(LIBS)
+nullmailer-localqueue$(EXEEXT): $(nullmailer_localqueue_OBJECTS) $(nullmailer_localqueue_DEPENDENCIES) 
+	@rm -f nullmailer-localqueue$(EXEEXT)
+	$(CXXLINK) $(nullmailer_localqueue_LDFLAGS) $(nullmailer_localqueue_OBJECTS) $(nullmailer_localqueue_LDADD) $(LIBS)
 nullmailer-send$(EXEEXT): $(nullmailer_send_OBJECTS) $(nullmailer_send_DEPENDENCIES) 
 	@rm -f nullmailer-send$(EXEEXT)
 	$(CXXLINK) $(nullmailer_send_LDFLAGS) $(nullmailer_send_OBJECTS) $(nullmailer_send_LDADD) $(LIBS)
