protocols = imap pop3 imaps pop3s managesieve
listen = 0.0.0.0
login_greeting = Servidor de correo preparado.
disable_plaintext_auth = no
ssl_cert_file = /etc/ssl/certs/dovecot.crt
ssl_key_file = /etc/ssl/private/dovecot.key
log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot-info.log
mail_uid = mailuser
mail_gid = mailgroup

# IMAP configuration
protocol imap {
    login_executable = /usr/lib/dovecot/imap-login
    # Sustituimos el valor real del programa mail_executable, por un script para llevar un control sobre el último
    # inicio de sesión de los usuarios. Este script llama al final al valor real de mail_executable.
    # mail_executable = /usr/lib/dovecot/imap
    mail_executable = /usr/lib/dovecot/imap-postlogin
    mail_plugins = quota imap_quota autocreate antispam
}

# POP3 configuration
protocol pop3 {
    login_executable = /usr/lib/dovecot/pop3-login
    # Sustituimos el valor real del programa mail_executable, por un script para llevar un control sobre el último
    # inicio de sesión de los usuarios. Este script llama al final al valor real de mail_executable.
    # mail_executable = /usr/lib/dovecot/pop3
    mail_executable = /usr/lib/dovecot/pop3-postlogin

    pop3_uidl_format = %08Xu%08Xv
    mail_plugins = quota
}

# LDA configuration
protocol lda {
    log_path = /var/log/dovecot-lda.log
    postmaster_address = postmaster
    auth_socket_path = /var/run/dovecot/auth-master
    mail_plugins = quota cmusieve autocreate
    sieve_global_dir = /var/vmail/sieve/
    sieve_global_path = /var/vmail/sieve/global
}

protocol managesieve {

    # IP or host address where to listen in for connections. 
    listen = *:2000
    
    # Login executable location. 
    login_executable = /usr/lib/dovecot/managesieve-login

    # managesieve executable location. See mail_executable for IMAP for examples how this could be changed. 
    mail_executable = /usr/lib/dovecot/managesieve

    # Maximum managesieve command line length in bytes. This setting is directly borrowed from IMAP. But, since
    # long command lines are very unlikely with ManageSieve, changing this will not be very useful. 
    managesieve_max_line_length = 65536

    # This specifies the path to the directory where the uploaded scripts are stored. In terms of '%' variable
    # substitution it is identical to dovecot's mail_location setting used by the mail protocol daemons. Scripts 
    # are stored as separate files with extension .sieve, all other files are ignored when scripts are listed by
    # a ManageSieve client. If this setting remains unspecified, the mail_location setting is used as explained
    # below. 
    sieve_storage =

    # Specifies the location of the symbolic link pointing to the active script in the sieve storage directory.
    # This must match the sieve setting used by deliver. Variable substitution with % is recognized. If a regular
    # file exists at this location, it is moved to the sieve_storage location before the symbolic link is installed.
    # It is renamed to dovecot.orig.sieve and therefore listed as dovecot.orig by a ManageSieve client. 
    sieve = ~/.dovecot.sieve

    # If, for some inobvious reason, the sieve_storage remains unset, the managesieve daemon uses the specification
    # of the mail_location to find out where to store the sieve files. However, this is provided only for backwards
    # compatibility and you should always use the sieve_storage setting in stead. 
    mail_location =

    # To fool ManageSieve clients that are focused on CMU's timesieved you can specify the IMPLEMENTATION capability
    # that the dovecot reports to clients (e.g. 'Cyrus timsieved v2.2.13'). 
    managesieve_implementation_string = dovecot

}


# LDAP authentication

auth default {

    mechanisms = plain login

    passdb ldap {
        args = /etc/dovecot/dovecot-ldap.conf
    }

    userdb ldap {
        args = /etc/dovecot/dovecot-ldap.conf
    }

    socket listen {
        master {
            path = /var/run/dovecot/auth-master
            mode = 0660
            user = dovecot
            group = mail
        }

        client {
            path = /var/spool/postfix/private/auth
            mode = 0660
            user = postfix
            group = postfix
        }
    }
}

plugin {

    ##################
    # AUTOCREATE GENERIC OPTIONS

    autocreate = Sent
    autocreate2 = Trash
    autocreate3 = Draft
    autocreate4 = Junk

    autosubscribe = Sent
    autosubscribe2 = Trash
    autosubscribe3 = Draft
    autosubscribe4 = Junk


    ##################
    # ANTISPAM GENERIC OPTIONS

    # mail signature (used with any backend requiring a signature)
    antispam_signature = X-Dovecot-Antispam-Signature

    # semicolon-separated list of Trash folders (default unset i.e. none)
    # antispam_trash =
    # antispam_trash = trash;Trash;Deleted Items
    antispam_trash = Trash

    # semicolon-separated list of spam folders
    antispam_spam = Junk

    # semicolon-separated list of unsure folders (default unset i.e. none)
    # antispam_unsure =
    antispam_unsure = 

    # Whether to allow APPENDing to SPAM folders or not. Must be set to
    # "yes" (case insensitive) to be activated. Before activating, please
    # read the discussion below.
    # antispam_allow_append_to_spam = no
    antispam_allow_append_to_spam = no

    ###########################
    # ANTISPAM BACKEND SPECIFIC OPTIONS
    #

    #=====================
    # mail sending plugin
    #
    # Because of the way this plugin works, you can also use it
    # to train via an arbitrary program that receives the message
    # on standard input, in that case you can use the config
    # options antispam_mail_spam and antispam_mail_notspam for
    # the argument that distinguishes between ham and spam.
    # For example:
    #   antispam_mail_sendmail = /path/to/mailtrain
    #   antispam_mail_sendmail_args = --for;%u
    #   antispam_mail_spam = --spam
    #   antispam_mail_notspam = --ham
    # will call it, for example, like this:
    #   /path/to/mailtrain --for jberg --spam

    # temporary directory
    antispam_mail_tmpdir = /tmp

    # spam/not-spam addresses (default unset which will give errors)
    # antispam_mail_spam =
    antispam_mail_spam = --spam
    # antispam_mail_notspam =
    antispam_mail_notspam = --ham

    # sendmail binary
    #antispam_mail_sendmail = /usr/sbin/sendmail
    #antispam_mail_sendmail_args = -f;%u@example.com # % expansion done by dovecot
    antispam_mail_sendmail = /usr/bin/sa-learn
    antispam_mail_sendmail_args = -D

}

