{
    $OUT = '';

    use esmith::config;
    use esmith::db;

    my %accounts;
    tie %accounts, 'esmith::config', '/home/e-smith/accounts';

    # get $USERNAME from esmith::config - put there by the
    # email-update-user action as a temporary variable
    die "Username argument missing." unless defined ($USERNAME);

    my $type = db_get_type(\%accounts, $USERNAME);

    die
	"Account $USERNAME is not a user account; "
	. "update email forwarding failed.\n"
	    unless $type eq 'user';

    my $EmailForward = db_get_prop(\%accounts, $USERNAME, "EmailForward");
    my $ForwardAddress = db_get_prop(\%accounts, $USERNAME, "ForwardAddress");

    my $local_delivery = "";
    my $dt = $qmail{DeliveryType} || '';
    if ($dt eq 'program')
    {
	$local_delivery .= '| ';
    }
    my $di = $qmail{DeliveryInstruction} || './Maildir/';
    $local_delivery .= $di;

    if ($EmailForward eq "local")
    {
	$OUT = $local_delivery;
    }
    elsif ($EmailForward eq 'forward')
    {
	$OUT = "&" . $ForwardAddress . "\n";
    }
    elsif ($EmailForward eq 'both')
    {
	$OUT = "&" . $ForwardAddress . "\n";
	$OUT .= $local_delivery;
    }
    else
    {
	# this shouldn't happen - if it does, deliver locally
	$OUT = "./Maildir/\n";
    }
}
