#
# Change -e flag behaviour for vadddomain.
#  -e contains an @: forward as normal
#  -e without an @: treat as name of user into whose Maildir to deliver
#
# e.g.:
#  -e postmaster@forward.com
#    fridge# cat forward.com/.qmail-default 
#    | /usr/local/vpopmail/bin/vdelivermail '' postmaster@forward.com
#
#  -e postmaster
#    fridge# cat maildir.org/.qmail-default 
#    | /usr/local/vpopmail/bin/vdelivermail '' /usr/local/vpopmail/domains/maildir.org/postmaster
#
# James Raftery <james@now.ie> 8th Jan. 2003.
#
--- vadddomain.c.orig	Wed Jan  8 19:08:48 2003
+++ vadddomain.c	Wed Jan  8 19:32:41 2003
@@ -82,19 +82,26 @@
         vsetuserquota( "postmaster", Domain, Quota ); 
     }
     if ( BounceEmail[0] != 0 ) {
-        if ( strstr(BounceEmail, "@") != NULL ) { 
-            vget_assign(Domain, a_dir, 156, &a_uid, &a_gid );
-            snprintf(TmpBuf1, MAX_BUFF, "%s/.qmail-default", a_dir);
-            if ( (fs = fopen(TmpBuf1, "w+"))!=NULL) {
+        vget_assign(Domain, a_dir, 156, &a_uid, &a_gid );
+        snprintf(TmpBuf1, MAX_BUFF, "%s/.qmail-default", a_dir);
+        if ( (fs = fopen(TmpBuf1, "w+"))!=NULL) {
+
+            if ( strstr(BounceEmail, "@") != NULL ) { 
                 fprintf(fs, "| %s/bin/vdelivermail '' %s\n", VPOPMAILDIR, 
                     BounceEmail);
-                fclose(fs);
-                chown(TmpBuf1, a_uid, a_gid);
+
+            /* No '@' - assume it's a mailbox name */
+            /* James Raftery <james@now.ie> 8th. Jan. 2003 */
             } else {
-                printf("Error: could not open %s\n", TmpBuf1);
+                fprintf(fs, "| %s/bin/vdelivermail '' %s/%s\n", VPOPMAILDIR,
+                    a_dir, BounceEmail);
             }
+
+            fclose(fs);
+            chown(TmpBuf1, a_uid, a_gid);
+
         } else {
-            printf("Invalid bounce email address %s\n", BounceEmail);
+            printf("Error: could not open %s\n", TmpBuf1);
         }
     }
     if ( RandomPw == 1 ) printf("Random password: %s\n", Passwd );
@@ -108,7 +115,7 @@
 	printf("options: -v prints the version\n");
 	printf("         -q quota_in_bytes (sets the quota for postmaster account)\n");
 	printf("         -b (bounces all mail that doesn't match a user, default)\n");
-	printf("         -e email_address (forwards all non matching user to this address)\n");
+	printf("         -e email_address (forwards all non matching user to this address [*])\n");
 	printf("         -u user (sets the uid/gid based on a user in /etc/passwd)\n");
 	printf("         -d dir (sets the dir to use for this domain)\n");
 	printf("         -i uid (sets the uid to use for this domain)\n");
@@ -117,6 +124,8 @@
 	printf("         -O optimize adding, for bulk adds set this for all\n");
 	printf("            except the last one\n");
 	printf("         -r generate a random password for postmaster\n");
+	printf("\n");
+	printf(" [*] omit @-sign to deliver directly into user's Maildir: '-e postmaster'\n");
 	exit(0);
 }
 

