{
    # This snippet sets the managesieve_port config option of the plugin if Sieve service is enabled
    # otherwise, the default value of "null" is kept for this config option.

    use esmith::ConfigDB;
    my $cdb = esmith::ConfigDB->open_ro || die "Couldn't open ConfigDB\n";

    my $sievestatus  = $cdb->get_prop('sieve','status') || 'disabled';
    my $sieveport    = $cdb->get_prop('sieve','TCPPort') || 'null';
  
    $OUT .= "// managesieve server port. When empty the port will be determined automatically\n";
    $OUT .= "// using getservbyname() function, with 4190 as a fallback.\n";
     
    if ($sievestatus eq 'enabled') {
        $OUT .= "\$config['managesieve_port'] = $sieveport; \n";
    }
    else {
        $OUT .= "\$config['managesieve_port'] = null; \n";
    }
    $OUT .= "// managesieve server address (and optional port), default is localhost.\n";
    $OUT .= "// Replacement variables supported in host name:\n";
    $OUT .= "// %h - user's IMAP hostname\n";
    $OUT .= "// %n - http hostname ($_SERVER['SERVER_NAME'])\n";
    $OUT .= "// %d - domain (http hostname without the first part)\n";
    $OUT .= "// For example %n = mail.domain.tld, %d = domain.tld\n";
    $OUT .= "// If port is omitted it will be determined automatically using getservbyname()\n";
    $OUT .= "// function, with 2000 or 4190 as a fallback (depending on current version).\n";
    $OUT .= "// Note: Add tls:// prefix to enable explicit STARTTLS\n";
    $OUT .= "// or add ssl:// prefix to enable implicit SSL.\n";
    if ($sievestatus eq 'enabled') {
        $OUT .= "\$config['managesieve_host'] = 'localhost:$sieveport'; \n";
    }
    else {
        $OUT .= "\$config['managesieve_host'] = null; \n";
    }


}
