Setup changes 1.x to 2.x -- custom POP3 account handling required.

Andrew McGlashan andrew.mcglashan at affinityvision.com.au
Mon Feb 22 06:52:39 UTC 2016


Hi,

Previously I did /special/ processing for some email accounts; if a
particular file existed in the user's home directory, then I caused the
account to use /var/mail/$USER file for POP -- otherwise it used IMAP.

Now, because I adjusted the setup for POP only, IMAP still worked
perfectly well.  Some users have both POP and IMAP access for various
reasons.

The special POP processing was done using a shell script [1] in place of:
   /usr/lib/dovecot/pop3
 - which in turn called the normal binary once setting up the
   environment.

Now, I have been forced to upgrade my Debian from squeeze-lts to wheezy
and the dovecot setup is quite different.

How can I implement my /wrapper/ script for POP handling now?

Here is my current setup with dovecot -n ...

# 2.1.7: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-5-xen-amd64 x86_64 Debian 7.9
mail_location = maildir:~/Maildir
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Items" {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  driver = pam
}
plugin {
  sieve = ~/.dovecot.sieve
  sieve_dir = ~/sieve
}
protocols = " imap pop3"
service imap-login {
  inet_listener imap {
    port = 0
  }
}
service pop3-login {
  inet_listener pop3 {
    port = 0
  }
}
ssl = required
ssl_cert = </etc/exim4/exim.crt
ssl_key = </etc/exim4/exim.key
userdb {
  driver = passwd
}


[1] This is the content of the original wrapper script:

#!/bin/sh

if [ -f $HOME/.use-mbox-for-pop3s ]; then
        export MAIL=mbox:$HOME/mail:INBOX=/var/mail/$USER
        export USER_INBOX=/var/mail/$USER
        if [ -f $USER_INBOX ]
        then
                export USER_INBOX_GROUP=$(stat -c %G $USER_INBOX)
                if [ $USER_INBOX_GROUP != $USER ]
                then
                        (
                        date
                        ls -l $USER_INBOX
                        chown Debian-exim:$USER $USER_INBOX
                        ls -l $USER_INBOX
                        ) >> /var/log/usr-lib-dovecot--pop3-affinity.log
                fi
        fi
else
        if [ -d $HOME/Maildir ]; then
                export MAIL=Maildir:$HOME/Maildir
        else
                export MAIL=mbox:$HOME/mail:INBOX=/var/mail/$USER
        fi
fi

# Finally execute the imap/pop3. If you use both, you'll need two scripts.
# - this customization just for POP3S ...
exec /usr/lib/dovecot/pop3



Thanks
AndrewM


More information about the dovecot mailing list