Setting up a Dovecot POP3 server for retrieving Jira mail from a virtual mailbox

Installation

sudo apt-get install dovecot-pop3d

Configuration for plaintext authentication

  1. Edit the /etc/dovecot/dovecot.conf file, find the section starting with:
#disable_plaintext_auth = true

set it to:

disable_plaintext_auth = no

Next find:

auth default {
  # Space separated list of wanted authentication mechanisms:
  #   plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi
  mechanisms = plain

Change this to:

  mechanisms = pop3
  1. just after the block:
     userdb passwd {
    

    Add this:

    passdb passwd-file {
         args = /etc/dovecot/auth/jira.myco.net/passwd
     }
    userdb static {
          args = uid=7000 gid=7000 mail=mbox:/var/mail/vhosts/%d/%n nice=10
     }
    
  2. Enable logging and debugging just after:
    ##
    ## Mail processes
    ##
    

    So that:

    mail_debug = yes
    
  3. Setup the password file
    sudo mkdir -p /etc/dovecot/auth/jira.myco.net
    sudo echo "shared@jira.myco.net:{plain}secret" >/etc/dovecot/auth/jira.myco.net/passwd
    
  4. Create the user that the logged in POP3 session runs under
    addgroup --gid 7000 jiramboxuser
    adduser --uid 7000 --gid 7000 --no-create-home --disabled-login jiramboxuser
    
  5. Create the virtual mailbox that pop3 will use
    chmod -R -s /var/mail/vhosts/
    sudo mkdir -p /var/mail/vhosts/jira.myco.net/shared
    sudo touch /var/mail/vhosts/jira.myco.net/shared/inbox
    chown -R postfix:jiramboxuser /var/mail/vhosts/jira.myco.net
    sudo chmod -R 770 /var/mail/vhosts/jira.myco.net/
    sudo chmod 660 /var/mail/vhosts/jira.myco.net/shared/inbox
    

    see PasswdFile for more details on the passwd file format

  6. Restart dovecot in a new console
    Any pop3 activity will be logged out to this console
    /etc/init.d dovecot restart &
    

Testing

See dovecot page TestPop3Installation for more details.

  1. Run evolution, its installed by default, or if you chose not to:
    sudo apt-get install evolution
    
  2. Add a new pop3 mailbox setup
    • Edit/Preferences
    • Add mail account
    • Enter a "Name" of Jira Mail, and an "email address" of shared@jira.myco.net, then click Forward
    • Set "Server Type" to POP, the "Server" to be localhost, the "username" to shared@jira.myco.net, and check "remember password", click Forward
    • Set "check for new messages every" to 1 minute, check the "lave messages on server" - let Jira deal with this, click Forward
    • For delivery of mail, set the type to "Sendmail" and click Forward
    • When shown the account details, again, just click Forward
    • Back at the Evolution view, just click Send/Receive. Enter the password set above (secret).
    • You should now see a new mail waiting

Debugging

The Dovecot server is very particular about file permissions. If the config files cannot be read or the access is not permitted to the inbox, it won't work. Patience, and logging will help.

The following fields in the /etc/dovecot/dovecot.conf file are useful to debug dovecot problems:

auth_verbose = yes
auth_debug = yes

Example logging output:

dovecot: 2008-09-26 14:05:23 Info: POP3(shared@jira.myco.net): Effective uid=7000, gid=7000
dovecot: 2008-09-26 14:05:23 Info: POP3(shared@jira.myco.net): mbox: data=/var/mail/vhosts/jira.myco.net/shared
dovecot: 2008-09-26 14:05:23 Info: POP3(shared@jira.myco.net): mbox: INBOX defaulted to /var/mail/vhosts/jira.myco.net/shared/inbox
dovecot: 2008-09-26 14:05:23 Info: POP3(shared@jira.myco.net): mbox: root=/var/mail/vhosts/jira.myco.net/shared, index=/var/mail/vhosts/jira.myco.net/shared, inbox=/var/mail/vhosts/jira.myco.net/shared/inbox
dovecot: 2008-09-26 14:05:23 Error: POP3(shared@jira.myco.net): mkdir_parents(/var/mail/vhosts/jira.myco.net/shared/.imap/INBOX) failed: Permission denied
dovecot: 2008-09-26 14:05:23 Info: pop3-login: Login: user=<shared@jira.myco.net>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
dovecot: 2008-09-26 14:05:23 Info: POP3(shared@jira.myco.net): Disconnected: Logged out top=0/0, retr=0/0, del=0/5, size=2010
dovecot: 2008-09-26 14:05:24 Info: auth(default): new auth connection: pid=9697

Configuration for SSL authentication

todo

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.