--- sendmail.c.orig  1998-06-15
+++ sendmail.c       2007-03-21
--- .././qmail-1.03/sendmail.c	Mon Jun 15 12:53:16 1998
+++ ../qmail-1.03.2418/sendmail.c	Mon Nov 22 21:55:35 2004
@@ -45,6 +45,38 @@
   _exit(111);
 }
 
+void do_sender(s)
+const char *s;
+{
+  char *x;
+  int n;
+  int a;
+  int i;
+
+  env_unset("QMAILNAME");
+  env_unset("MAILNAME");
+  env_unset("NAME");
+  env_unset("QMAILHOST");
+  env_unset("MAILHOST");
+
+  n = str_len(s);
+  a = str_rchr(s, '@');
+  if (a == n)
+  {
+    env_put2("QMAILUSER", s);
+    return;
+  }
+  env_put2("QMAILHOST", s + a + 1);
+
+  x = (char *) alloc((a + 1) * sizeof(char));
+  if (!x) nomem();
+  for (i = 0; i < a; i++)
+    x[i] = s[i];
+  x[i] = 0;
+  env_put2("QMAILUSER", x);
+  alloc_free(x);
+}
+
 int flagh;
 char *sender;
 
@@ -66,6 +98,7 @@
   sender = 0;
   while ((opt = getopt(argc,argv,"vimte:f:p:o:B:F:EJxb:")) != opteof)
     switch(opt) {
+      case 'N': break; /* ignore DSN option */
       case 'B': break;
       case 't': flagh = 1; break;
       case 'f': sender = optarg; break;
@@ -118,6 +151,7 @@
   if (sender) {
     *arg++ = "-f";
     *arg++ = sender;
+    do_sender(sender);
   }
   *arg++ = "--";
   for (i = 0;i < argc;++i) *arg++ = argv[i];


syntax highlighted by Code2HTML, v. 0.9.1