Maintain Trash and Spam folder and Vpopmail - roaming users configuration: Difference between pages

From QmailToaster
(Difference between pages)
Jump to navigation Jump to search
(Created page with " #!/bin/bash # qtprune.sh # # This file can be put in /etc/cron.daily # and will prune Trash/Spam directories # Nov 7, 2006 # # 3/5/2007 Added date configuration capability # # Erik A. Espinoza <espinoza@kabewm.com # # # # Number of days for Trasn TRASH_DAYS="28" # Number of days for Spam SPAM_DAYS="28" # Find Trash Dir PATH_TRASH="`find /home/vpopmail/domains -type d -name .Trash`" # Find Spam Dir PATH_SPAM="`find /home/vpopmail/domains -type d -nam...")
 
(Created page with "===Vpopmail - roaming users configuration=== If you want to use the vpopmail roaming users configuration option here area few steps to follow : 1. rpm -Uvh vpopmail-toaster*.src.rpm go to (if you didnt set your own .rpmmacros config) /usr/src/redhat/SPECS and edit the file vpopmail-toaster.spec look for the configure options .. (./configure --prefix ....) line and change --disable-roaming-users into --enable-roaming-users .. If you want to add/re...")
 
Line 1: Line 1:
#!/bin/bash
===[[Vpopmail - roaming users configuration]]===


# qtprune.sh
If you want to use the vpopmail roaming users configuration option
#
here area few steps to follow :
# This file can be put in /etc/cron.daily
# and will prune Trash/Spam directories
# Nov 7, 2006
#
# 3/5/2007 Added date configuration capability
#
# Erik A. Espinoza <espinoza@kabewm.com
#
#
#
# Number of days for Trasn
TRASH_DAYS="28"
# Number of days for Spam
SPAM_DAYS="28"
# Find Trash Dir
PATH_TRASH="`find /home/vpopmail/domains -type d -name .Trash`"
  # Find Spam Dir
PATH_SPAM="`find /home/vpopmail/domains -type d -name .Spam`"


1. rpm -Uvh vpopmail-toaster*.src.rpm
  go to (if you didnt set your own .rpmmacros config) /usr/src/redhat/SPECS
  and edit the file vpopmail-toaster.spec
  look for the configure options ..
  (./configure --prefix ....) line and change --disable-roaming-users
  into --enable-roaming-users ..
  If you want to add/remove other options do it now..


# Exit if no spam or trash directories found
2. rpmbuild -bb --with [your_distro] vpopmail-toaster.spec
if [ -z "${PATH_TRASH}" ] && [ -z "${PATH_SPAM}" ]; then
  just wait after issuing that command
    exit 0
  cd ../RPMS/i386
fi
  STOP qmail : /etc/init.d/qmail stop  or qmailctl stop
  rpm -Uvh --replacefiles --replacepkgs vpopmail-toaster*.rpm
  IF you keep RPMS make sure you point to the one you just rebuilt not
  and old one ...
  START qmail : /etc/init.d/qmail start  or qmailctl start


# Delete Trash older than $TRASH_DAYS days
3. The roaming system authorize a user who authentificated (pop3 before smtp)
# if Trash directories found
  the right to relay, it adds your ip to the cdb file
if [ -n "${PATH_TRASH}" ]; then
  /etc/tcprules.d/tcp.smtp.cdb .. This file must be owned by vpopmail.vchkpw
    for each in "${PATH_TRASH}" ; do
  do this now :
        FILES_TO_DELETE="`find ${each} -type f -ctime +${TRASH_DAYS}`"
  chown vpopmail.vchkpw /etc/tcprules.d/tcp.smtp.cdb
        if [ -n "${FILES_TO_DELETE}" ]; then
          for file in ${FILES_TO_DELETE} ; do
              if [ -n ${file} ]; then
                  rm -f ${file}  >/dev/null 2>&1
              fi
          done
        fi
    done
fi


# Learn and Delete Spam older than $SPAM_DAYS
  Then edit /etc/init.d/qmail
# days if Spam directories found
  look for the section cdb) :
if [ -n "${PATH_SPAM}" ]; then
    cdb)
     for each in "${PATH_SPAM}" ; do
     tcprules /etc/tcprules.d/tcp.smtp.cdb /etc/tcprules.d/tcp.smtp.tmp < /etc/tcprules.d/tcp.smtp
        FILES_TO_DELETE="`find ${each} -type f -ctime +${SPAM_DAYS}`"
    chmod 644 /etc/tcprules.d/tcp.smtp*
        if [ -n "${FILES_TO_DELETE}" ]; then
add here -> '''chown vpopmail.vchkpw /etc/tcprules.d/tcp.smtp.cdb'''  <-
          for file in ${FILES_TO_DELETE} ; do
     echo "Reloaded /etc/tcprules.d/tcp.smtp" 
              if [ -n ${file} ]; then
                  sudo -u vpopmail -H sa-learn --spam ${file}  >/dev/null 2>&1
                  rm -f ${file} >/dev/null 2>&1
              fi
          done
        fi
     done
fi


The purpose of this, whenever you reload your cdb files
it will give you the proper rights and ownership on the file


exit 0
4. By default it is 3 hours (180mins) authorization after pop authentification
# EOF
  for roaming users
  I d suggest to set a crontab to check the ips allowed to relay
  I chose every 30mins
  0,30 * * * * /home/vpopmail/bin/clearopensmtp


  NB: you could change the default time by adding this configure option :
      --enable-relay-clear-minutes=#  to the spec file


Below is the modified script to maintain Draft, Sent, Trash and Spam in one shots.
Also note that roaming access is only available to users checking mail via POP3. If you have users who connect via POP3-SSL, IMAP, or IMAP-SSL they are ''not'' added to the list of authenticated users. See this thread for more info: http://www.mail-archive.com/vchkpw@inter7.com/msg24375.html
 
#!/bin/bash
# qtprune.sh
#
# This file can be put in /etc/cron.daily
# and will prune Trash/Spam directories
# Nov 7, 2006
#
# 3/5/2007 Added date configuration capability
#
# Erik A. Espinoza <espinoza@kabewm.com>
#
#
# 8/20/2007 Added pruning for Sent dan Draft folders
# PakOgah <pakogah@pala.bo-tak.info>
#
# Number of days for Trash
TRASH_DAYS="30"
# Number of days for Spam
SPAM_DAYS="30"
# Number of days for Sent
SENT_DAYS="90"
# Number of days for Drafts
DRAFTS_DAYS="90"
# Number of days for keeping email
EMAIL_DAYS="31"
# Find Trash Dir
PATH_TRASH="`find /home/vpopmail/domains -type d -name .Trash`"
# Find Spam Dir
PATH_SPAM="`find /home/vpopmail/domains -type d -name .Spam`"
# Find Sent Dir
PATH_SENT="`find /home/vpopmail/domains -type d -name .Sent`"
# Find Drafts Dir
PATH_DRAFTS="`find /home/vpopmail/domains -type d -name .Drafts`"
# Find Email dir ( cur )
PATH_EMAIL="`find /home/vpopmail/domains -type d -name .cur`"
# Exit if no spam or trash directories found
if [ -z "${PATH_TRASH}" ] && [ -z "${PATH_SPAM}" ] && [ -z "${PATH_SENT}" ] && [ -z "${PATH_DRAFTS}" ]; then
    exit 0
fi
# Delete Trash older than $TRASH_DAYS days
# if Trash directories found
if [ -n "${PATH_TRASH}" ]; then
    for each in "${PATH_TRASH}" ; do
        FILES_TO_DELETE="`find ${each} -type f -ctime +${TRASH_DAYS}`"
        if [ -n "${FILES_TO_DELETE}" ]; then
          for file in ${FILES_TO_DELETE} ; do
              if [ -n ${file} ]; then
                  rm -f ${file}  >/dev/null 2>&1
              fi
          done
        fi
    done
fi
# Delete Sent older than $SENT_DAYS days
# if Sent directories found
if [ -n "${PATH_SENT}" ]; then
    for each in "${PATH_SENT}" ; do
        FILES_TO_DELETE="`find ${each} -type f -ctime +${SENT_DAYS}`"
        if [ -n "${FILES_TO_DELETE}" ]; then
          for file in ${FILES_TO_DELETE} ; do
              if [ -n ${file} ]; then
                  rm -f ${file}  >/dev/null 2>&1
              fi
          done
        fi
    done
fi
# Delete Drafts older than $DRAFTS_DAYS days
# if Drafts directories found
if [ -n "${PATH_DRAFTS}" ]; then
    for each in "${PATH_DRAFTS}" ; do
        FILES_TO_DELETE="`find ${each} -type f -ctime +${DRAFTS_DAYS}`"
        if [ -n "${FILES_TO_DELETE}" ]; then
          for file in ${FILES_TO_DELETE} ; do
              if [ -n ${file} ]; then
                  rm -f ${file}  >/dev/null 2>&1
              fi
          done
        fi
    done
fi
# Learn and Delete Spam older than $SPAM_DAYS
# days if Spam directories found
if [ -n "${PATH_SPAM}" ]; then
    for each in "${PATH_SPAM}" ; do
        FILES_TO_DELETE="`find ${each} -type f -ctime +${SPAM_DAYS}`"
        if [ -n "${FILES_TO_DELETE}" ]; then
          for file in ${FILES_TO_DELETE} ; do
              if [ -n ${file} ]; then
                  sudo -u vpopmail -H sa-learn --spam ${file}  >/dev/null 2>&1
                  rm -f ${file}  >/dev/null 2>&1
              fi
          done
        fi
    done
fi
# Delete Emails older than $EMAIL_DAYS days
# if EMAIL directories found
if [ -n "${PATH_EMAIL}" ]; then
    for each in "${PATH_EMAIL}" ; do
        FILES_TO_DELETE="`find ${each} -type f -ctime +${EMAIL_DAYS}`"
        if [ -n "${FILES_TO_DELETE}" ]; then
          for file in ${FILES_TO_DELETE} ; do
              if [ -n ${file} ]; then
                rm -f ${file}  >/dev/null 2>&1
              fi
          done
      fi
  done
fi
exit 0
# EOF
 
Or if you just want to maintain Spam folder you can run
# qtp-clean-spam
from QTP tools

Latest revision as of 10:30, 16 March 2024

Vpopmail - roaming users configuration

If you want to use the vpopmail roaming users configuration option here area few steps to follow :

1. rpm -Uvh vpopmail-toaster*.src.rpm

  go to (if you didnt set your own .rpmmacros config) /usr/src/redhat/SPECS
  and edit the file vpopmail-toaster.spec
  look for the configure options ..
  (./configure --prefix ....) line and change --disable-roaming-users
  into --enable-roaming-users ..
  If you want to add/remove other options do it now..

2. rpmbuild -bb --with [your_distro] vpopmail-toaster.spec

  just wait after issuing that command
  cd ../RPMS/i386
  STOP qmail : /etc/init.d/qmail stop   or qmailctl stop
  rpm -Uvh --replacefiles --replacepkgs vpopmail-toaster*.rpm 
  IF you keep RPMS make sure you point to the one you just rebuilt not
  and old one ...
  START qmail : /etc/init.d/qmail start   or qmailctl start

3. The roaming system authorize a user who authentificated (pop3 before smtp)

  the right to relay, it adds your ip to the cdb file
  /etc/tcprules.d/tcp.smtp.cdb .. This file must be owned by vpopmail.vchkpw
  do this now :
  chown vpopmail.vchkpw /etc/tcprules.d/tcp.smtp.cdb
  Then edit /etc/init.d/qmail
  look for the section cdb) :
   cdb)
   tcprules /etc/tcprules.d/tcp.smtp.cdb /etc/tcprules.d/tcp.smtp.tmp < /etc/tcprules.d/tcp.smtp
   chmod 644 /etc/tcprules.d/tcp.smtp*

add here -> chown vpopmail.vchkpw /etc/tcprules.d/tcp.smtp.cdb <-

   echo "Reloaded /etc/tcprules.d/tcp.smtp"   

The purpose of this, whenever you reload your cdb files it will give you the proper rights and ownership on the file

4. By default it is 3 hours (180mins) authorization after pop authentification

  for roaming users
  I d suggest to set a crontab to check the ips allowed to relay
  I chose every 30mins
  0,30 * * * * /home/vpopmail/bin/clearopensmtp
  NB: you could change the default time by adding this configure option :
      --enable-relay-clear-minutes=#  to the spec file

Also note that roaming access is only available to users checking mail via POP3. If you have users who connect via POP3-SSL, IMAP, or IMAP-SSL they are not added to the list of authenticated users. See this thread for more info: http://www.mail-archive.com/vchkpw@inter7.com/msg24375.html