LDA: Difference between revisions

From QmailToaster
Jump to navigation Jump to search
No edit summary
 
(36 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Dovecot|Back]]
[[Dovecot|Back]]<br><br>
 
==Dovecot LDA==
  # qmailctl stop
  # qmailctl stop
  # cd /home/vpopmail/domains/domain.tld
  # cd /home/vpopmail/domains/domain.tld
  # mv .qmail-default .qmail-default.bak
  # cp -p .qmail-default .qmail-default.bak
  # OPTIONS="| /usr/bin/dspam --user \$EXT@\$HOST --deliver=stdout --feature=no,wh \
  # cat > .qmail-default << __EOF__
            | /usr/bin/rspamc --mime \
| /usr/bin/dspam --user \$EXT@\$HOST --deliver=stdout --feature=no,wh \
            | /var/qmail/bin/preline -f /usr/libexec/dovecot/deliver -d \$EXT@\$USER"
| /usr/bin/rspamc --mime \
  # echo $OPTIONS > .qmail-default
| /var/qmail/bin/preline -f /usr/libexec/dovecot/deliver -d \$EXT@\$USER
# chown vpopmail:vchkpw .qmail-default && chmod 0600 .qmail-default
  __EOF__
# setfacl -m  u:vpopmail:rw,g:vchkpw:rw  /var/run/dovecot/stats-writer
  # mkdir /var/log/dovecot-lda && chmod 770 /var/log/dovecot-lda && chown vpopmail:vchkpw /var/log/dovecot-lda
  # mkdir /var/log/dovecot-lda
# chmod 770 /var/log/dovecot-lda
# chown vpopmail:vchkpw /var/log/dovecot-lda
  # touch /etc/logrotate.d/dovecot-lda
  # touch /etc/logrotate.d/dovecot-lda
  # cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.bak
  # cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.orig
  # cat >> /etc/dovecot/dovecot.conf << __EOF__
  # cat >> /etc/dovecot/dovecot.conf << __EOF__
#
# LDA
  protocol lda {
  protocol lda {
     deliver_log_format = From:<%f>-<%e> :: Subject:<%s> :: Status:<%$> :: MsgID:<%m> :: Size<%p> :: vSize<%w>
     deliver_log_format = From:<%f>-<%e> :: Subject:<%s> :: Status:<%$> :: MsgID:<%m> :: Size<%p> :: vSize<%w>
     log_path = /var/log/dovecot-lda/dovecot-lda-errors.log
     log_path = /var/log/dovecot-lda/dovecot-lda-errors.log
     info_log_path = /var/log/dovecot-lda/dovecot-lda.log
     info_log_path = /var/log/dovecot-lda/dovecot-lda.log
}
service stats {
    unix_listener stats-writer {
      group = vchkpw
    }
  }
  }
  __EOF__
  __EOF__
# systemctl restart dovecot
# qmailctl start


 
==Dovecot Sieve==
# cp -p /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.lda.orig
  # yum -y install dovecot-pigeonhole
  # yum -y install dovecot-pigeonhole
  Add to /etc/dovecot/dovecot.conf
  # mkdir /var/lib/dovecot/sieve
  mail_location = maildir:~/Maildir
# cat >> /etc/dovecot/dovecot.conf << __EOF__
  protocols = $protocols imap pop3 sieve
#
  plugin {
# Sieve
      sieve = ~/.dovecot.sieve
plugin {
      sieve_dir = ~/.sieve
  sieve = ~/.dovecot.sieve
  }
  sieve_global_path = /var/lib/dovecot/sieve/default.sieve
  service managesieve-login {
  sieve_dir = ~/sieve
      inet_listener sieve {
  sieve_global_dir = /var/lib/dovecot/sieve/
      port = 4190
}
      }
protocol lda {
  }
  mail_plugins = $mail_plugins sieve
  protocol lda {
}
      mail_plugins = $mail_plugins sieve
__EOF__
      .
# systemctl restart dovecot
      .
Global permissions
      .
# setfacl -m u:vpopmail:rwx,g:vchkpw:rx /var/lib/dovecot/sieve
  }
# setfacl -d -m u:vpopmail:rwx,g:vchkpw:rx /var/lib/dovecot/sieve
# setfacl -m u:vpopmail:rwx,g:vchkpw:rx /var/lib/dovecot
# setfacl -d -m u:vpopmail:rwx,g:vchkpw:rx /var/lib/dovecot
User permissions
  # cd /home/vpopmail/domains/domain.tld/user
  # cd /home/vpopmail/domains/domain.tld/user
  # mkdir .sieve
  # mkdir .sieve
Line 50: Line 60:
  # chown vpopmail:vchkpw .dovecot.sieve
  # chown vpopmail:vchkpw .dovecot.sieve
  # chmod 700 .sieve
  # chmod 700 .sieve
  Add Sieve rules to .sieve/user.sieve
Edit global file
  Enable Dovecot LDA formatted logging
  # cat >> /var/lib/dovecot/sieve/default.sieve << __EOF__
  Add to /etc/dovecot/dovecot.conf
require "fileinto";
  protocol lda {
if header :contains "X-Spam-Flag" "YES" {
        deliver_log_format = From:<%f>-<%e> :: Subject:<%s> :: Status:<%$> :: MsgID:<%m> :: Size<%p> :: vSize<%w>
    fileinto "spam";
        log_path = /var/log/dovecot-lda/dovecot-lda-errors.log
}
        info_log_path = /var/log/dovecot-lda/dovecot-lda.log
  __EOF__
  }
''sievec must be run whenever the sieve file is edited''
  # mkdir /var/log/dovecot-lda
  # sievec /var/lib/dovecot/sieve/default.sieve
# chmod 770 /var/log/dovecot-lda
 
  # chown vpopmail:vchkpw /var/log/dovecot-lda
==Manage Sieve==
  # touch /etc/logrotate.d/dovecot-lda
# cp -p /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.sieve.orig
  Enable Dovecot LDA for QMT
  # cat >> /etc/dovecot/dovecot.conf << __EOF__
  # Edit /home/vpopmail/domains/yourdomain.tld/.qmail-default
  #
  Remove '|/home/vpopmail/bin/vdelivermail '' bounce-no-mailbox'
  # Dovecot Manage Sieve
  Add '|/var/qmail/bin/preline -f /usr/libexec/dovecot/deliver -d $EXT@$USER -o postmaster_address=postmaster@yourdomain.tld'
  protocols = $protocols sieve
  service managesieve-login {
    inet_listener sieve {
    port = 4190
    }
}
__EOF__
  # systemctl restart dovecot
  # systemctl restart dovecot

Latest revision as of 16:58, 20 October 2024

Back

Dovecot LDA

# qmailctl stop
# cd /home/vpopmail/domains/domain.tld
# cp -p .qmail-default .qmail-default.bak
# cat > .qmail-default << __EOF__
| /usr/bin/dspam --user \$EXT@\$HOST --deliver=stdout --feature=no,wh \
| /usr/bin/rspamc --mime  \
| /var/qmail/bin/preline -f /usr/libexec/dovecot/deliver -d \$EXT@\$USER
__EOF__
# mkdir /var/log/dovecot-lda && chmod 770 /var/log/dovecot-lda && chown vpopmail:vchkpw /var/log/dovecot-lda
# touch /etc/logrotate.d/dovecot-lda
# cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.orig
# cat >> /etc/dovecot/dovecot.conf << __EOF__
#
# LDA
protocol lda {
   deliver_log_format = From:<%f>-<%e> :: Subject:<%s> :: Status:<%$> :: MsgID:<%m> :: Size<%p> :: vSize<%w>
   log_path = /var/log/dovecot-lda/dovecot-lda-errors.log
   info_log_path = /var/log/dovecot-lda/dovecot-lda.log
}
service stats {
   unix_listener stats-writer {
      group = vchkpw
   }
}
__EOF__
# systemctl restart dovecot
# qmailctl start

Dovecot Sieve

# cp -p /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.lda.orig
# yum -y install dovecot-pigeonhole
# mkdir /var/lib/dovecot/sieve
# cat >> /etc/dovecot/dovecot.conf << __EOF__
#
# Sieve
plugin {
  sieve = ~/.dovecot.sieve
  sieve_global_path = /var/lib/dovecot/sieve/default.sieve
  sieve_dir = ~/sieve
  sieve_global_dir = /var/lib/dovecot/sieve/
}
protocol lda {
  mail_plugins = $mail_plugins sieve
}
__EOF__
# systemctl restart dovecot

Global permissions

# setfacl -m u:vpopmail:rwx,g:vchkpw:rx /var/lib/dovecot/sieve
# setfacl -d -m u:vpopmail:rwx,g:vchkpw:rx /var/lib/dovecot/sieve
# setfacl -m u:vpopmail:rwx,g:vchkpw:rx /var/lib/dovecot
# setfacl -d -m u:vpopmail:rwx,g:vchkpw:rx /var/lib/dovecot

User permissions

# cd /home/vpopmail/domains/domain.tld/user
# mkdir .sieve
# touch .sieve/user.sieve
# ln -s .sieve/user.sieve .dovecot.sieve
# chown -R vpopmail:vchkpw .sieve
# chown vpopmail:vchkpw .dovecot.sieve
# chmod 700 .sieve

Edit global file

# cat >> /var/lib/dovecot/sieve/default.sieve << __EOF__
require "fileinto";
if header :contains "X-Spam-Flag" "YES" {
   fileinto "spam";
}
__EOF__

sievec must be run whenever the sieve file is edited

# sievec /var/lib/dovecot/sieve/default.sieve

Manage Sieve

# cp -p /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.sieve.orig
# cat >> /etc/dovecot/dovecot.conf << __EOF__
#
# Dovecot Manage Sieve
protocols = $protocols sieve
service managesieve-login {
   inet_listener sieve {
   port = 4190
   }
}
__EOF__
# systemctl restart dovecot