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

    $OUT = '';

    my $status = db_get_prop($confref, "fetchmail", "status")
							|| 'disabled';
    my $method = db_get_prop($confref, "fetchmail", "Method")
							|| 'standard';

    if ($status eq "enabled" && $method eq 'multidrop')
    {
	# Write a fetchmail command which connects to a POP
	# server, retrieves all mail from a single account,
	# and feeds it to the local SMTP server.

	my $envelopeSpec =
	    db_get_prop($confref, "fetchmail", "SecondaryMailEnvelope");
	my $SecondaryMailServer =
	    db_get_prop($confref, "fetchmail", "SecondaryMailServer");
	my $SecondaryMailAccount =
	    db_get_prop($confref, "fetchmail", "SecondaryMailAccount");
	my $SecondaryMailPassword =
	    db_get_prop($confref, "fetchmail", "SecondaryMailPassword");
	$envelopeSpec = defined $envelopeSpec ?
		"envelope \"$envelopeSpec\"\n" : "";

	my $verbosity = db_get_prop($confref, "fetchmail", "Verbosity")
		    || "--silent";

 	local %domains;
 	tie %domains, 'esmith::config', '/home/e-smith/domains';

 	my $locals = join(' ',
			    ("$DomainName",
				grep
				    {db_get_type(\%domains, $_) eq 'domain'}
					keys %domains));

	$OUT .= "# multi-drop configuration; fetchmail ";
	$OUT .= "retrieves all mail from a remote POP mailbox:\n";
	$OUT .= "\n";
	$OUT .= "/usr/bin/fetchmail --syslog $verbosity ";

	my $AuthenticationMethod =
	    db_get_prop($confref, "fetchmail", "AuthenticationMethod") 
		|| "password";
	$OUT .= "--auth $AuthenticationMethod ";

	$OUT .= "--fetchmailrc - <<EOF\n";
	$OUT .= "\n";
	$OUT .= "set postmaster \"postmaster\@$DomainName\"\n";
	$OUT .= "set bouncemail\n";
	$OUT .= "set properties \"\"\n";
	$OUT .= "\n";
	$OUT .= "poll $SecondaryMailServer\n";
	$OUT .= $envelopeSpec;
	$OUT .= "    protocol POP3\n";
	$OUT .= "    no dns\n";
	$OUT .= "    localdomains $locals\n";
	$OUT .= "       username \"$SecondaryMailAccount\" ";
	$OUT .= "password \"$SecondaryMailPassword\" to * here\n";
	$OUT .= "           smtphost localhost\n";
	$OUT .= "           fetchall\n";
	$OUT .= "           forcecr\n";
	$OUT .= "\n";
	$OUT .= "EOF";

    }
}
