config_query_option COURIER_OPTS \
  "Are you running Courier on a network with access to a DNS server?" \
  y \
  "--with-tcpddns" \
  "--without-tcpddns" &&

config_query_option COURIER_OPTS \
  "Compile IPv6 support?" \
  y \
  "--with-ipv6" \
  "--without-ipv6" &&

config_query_list COURIER_DBLIB \
  "Which database library do you want to use with Courier?" \
  gdbm \
  db &&

config_query_option COURIER_OPTS \
  "Enable automatic syncing of the mail queue? Disabling this may increase performance, but will reduce reliability and worsen mail queue corruption in the event op system failure." \
  y \
  "--with-explicitsync" \
  "--without-explicitsync" &&

config_query_option COURIER_OPTS \
  "Also sync the directory containing each file synced? Some believe this necessary for adequate file syncing on ext2." \
  n \
  "--with-dirsync" \
  "--without-dirsync" &&

config_query_option COURIER_OPTS \
  "Support accepting mail addressed to <user-xxx@domain.com>, for arbitrary values of xxx, as mail for <user@domain.com>?" \
  y \
  "--enable-local-extensions" \
  "--disable-local-extensions" &&

config_query_option COURIER_OPTS \
  "Do you wish for Courier to be paranoid when negotiating courier specific ESMTP extensions with remote servers?" \
  n \
  "--with-paranoid-smtpext" \
  "--without-paranoid-smtpext" &&

config_query COURIER_WEBMAIL \
  "Do you want to install and configure the webmail portion of Courier?" \
  y &&

if [ "${COURIER_WEBMAIL}" == "y" ]; then
  config_query_list COURIER_SSLWEBMAIL \
    "Would you like to enable SSL for the Webmail server?" \
    yes \
    login_only \
    no &&

  case "${COURIER_SSLWEBMAIL}" in
    yes)        COURIER_OPTS="$COURIER_OPTS --enable-https=auto"
                ;;
    login_only) COURIER_OPTS="$COURIER_OPTS --enable-https=login"
                ;;
    no)         COURIER_OPTS="$COURIER_OPTS --disable-https"
                ;;
  esac &&

  config_query_option COURIER_OPTS \
    "Do you want to enable spell checking in Courier's webmail? " \
    y \
    "--with-ispell" \
    "--without-ispell" &&

  if list_find "$COURIER_OPTS" "--with-ispell"; then
    config_query_list COURIER_SPELLCHECKER \
      "Which spell checker do you want to use?" \
      aspell \
      ispell
  fi &&

  config_query_option COURIER_OPTS \
    "Enable automatic monthly renaming of the IMAP Sent folder?" \
    y \
    "--enable-autorenamesent" \
    "--disable-autorenamesent"
fi &&

config_query COURIER_FAXES \
  "Do you want to use courier fax support?" \
  n &&

config_query_option COURIER_OPTS \
  "Enable workarounds for IMAP clients that have a buggy implementation of IMAP4rev1?" \
  n \
  "--enable-workarounds-for-imap-client-bugs" \
  "--disable-workarounds-for-imap-client-bugs" &&

config_query_option COURIER_OPTS \
  "Include the Trash folder in the IMAP quota usage?" \
  n \
  "--with-trashquota" \
  "--without-trashquota" &&

COURIER_OPTS=${COURIER_OPTS/--disable-unicode}  &&
COURIER_OPTS=${COURIER_OPTS/--disable-utf7-folder-encoding}
