    # sending mail, qmail version
    # In the case of qmail, we pass the original data back to
    # qmail-queue-real.  It reads the email on descriptor 0, and the
    # envelope on descriptor 1.

    my $pipe1 = new IO::Pipe;
    my $pipe2 = new IO::Pipe;

    my $pid;
    if ($pid = fork()) { # Parent
	$pipe1->writer;
	$pipe2->writer;

	print $pipe1 "$recipline\n";
	while (<$fh>) {
	    next if ($seen_xheader == 0 && m/^$X_HEADER_TAG:/o);
	    if ($seen_xheader == 0 && m/\A\r?\n\Z/) {
		print $pipe2 "$X_HEADER_TAG: $X_HEADER_LINE\n";
		$seen_xheader = 1;
	    }
	    print $pipe2 $_;
	}

	close($pipe1);
	close($pipe2);

	if (waitpid($pid, 0) == -1) {
	    do_exit($REGERR, __LINE__);
	} else {
	    # Pass up qmail-queue-real's error code
	    do_exit($? >> 8, __LINE__);
	}
    } elsif (defined $pid) { # Child
	$pipe1->reader;
	$pipe2->reader;

	close(STDOUT);
	fcntl($pipe1, F_DUPFD, 1);
	close($pipe1);

	close(STDIN);
	fcntl($pipe2, F_DUPFD, 0);
	close($pipe2);

	exec("$QMAILDIR/qmail-queue-real") || do_exit($REGERR, __LINE__);
    } else {
	# fork failed
	do_exit($REGERR, __LINE__);
    }
    # End qmail
