Linux – How to start dovecot

dovecotemail-serverlinuxUbuntu

I'm building a web server to host multiple websites. I got everything working except the mail server. I'm using linode to host my vps and I've been following their tutorials. FYI, I'm using Ubuntu 11.10.

Here is the link I've been following, http://library.linode.com/email/postfix/dovecot-mysql-ubuntu-10.04-lucid. I got up to the part where it tells me to restart dovecot, so I tried "service dovecot restart". But then I get this "restart: Unknown instance:". I'm logged in as root, so I'm not using sudo.

Since that didn't work I tried "/etc/init.d/dovecot restart" and I get "dovecot start/running, process 4760". So I try "/etc/init.d/dovecot status" and I get "dovecot stop/waiting".

So I tried "service dovecot start" and I get "dovecot start/running, process 4781". So I tried to get the status, so I tired "service dovecot status" and got "dovecot stop/waiting"

Then I tired "/etc/init.d/dovecot start" and I get "dovecot start/running, process 4794". So I tired to get the status, so I tired "/etc/init.d/dovecot status" and got "dovecot stop/waiting"

Just for kicks and giggles I tired to kill the process, I used the PID that I got when I did "service dovecot start", this was the command "kill -9 4444" and I get this "bash: kill: (4805) – No such process"

Am I doing something wrong?

–EDIT 1–

The following are logs that were found in /var/log/syslog that involved dovecot

dovecot: master: Dovecot v2.0.13 starting up (core dumps disabled)
dovecot: ssl-params: Generating SSL parameters
dovecot: ssl-params: SSL parameters regeneration completed
dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
dovecot: config: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
kernel: init: dovecot main process (10276) terminated with status 89
kernel: init: dovecot main process (10289) terminated with status 89
kernel: init: dovecot main process (10452) terminated with status 89
kernel: init: dovecot main process (2275) terminated with status 89
kernel: init: dovecot main process (3028) terminated with status 89
kernel: init: dovecot main process (3216) terminated with status 89
kernel: init: dovecot main process (3230) terminated with status 89
kernel: init: dovecot main process (3254) terminated with status 89
kernel: init: dovecot main process (3813) terminated with status 89
kernel: init: dovecot main process (3845) terminated with status 89
kernel: init: dovecot main process (4664) terminated with status 89
kernel: init: dovecot main process (4760) terminated with status 89
kernel: init: dovecot main process (4781) terminated with status 89
kernel: init: dovecot main process (4794) terminated with status 89
kernel: init: dovecot main process (4805) terminated with status 89

–Edit 2 (/etc/dovecot/dovecot.conf)–

The following is the dovecot.conf file

protocols = imap imaps pop3 pop3s
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/home/vmail/%d/%n/Maildir

ssl_cert_file = /etc/ssl/certs/dovecot.pem
ssl_key_file = /etc/ssl/private/dovecot.pem

namespace private {
    separator = .
    prefix = INBOX.
    inbox = yes
}

protocol lda {
    log_path = /home/vmail/dovecot-deliver.log
    auth_socket_path = /var/run/dovecot/auth-master
    postmaster_address = postmaster@[mydomainname.com]
    mail_plugins = sieve
    global_script_path = /home/vmail/globalsieverc
}

protocol pop3 {
    pop3_uidl_format = %08Xu%08Xv
}

auth default {
    user = root

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

    userdb static {
        args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
    }

    socket listen {
        master {
            path = /var/run/dovecot/auth-master
            mode = 0600
            user = vmail
        }

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

— Edit 3 (/var/log/mail.log) —

The following is what is in /var/log/mail.log

dovecot: master: Dovecot v2.0.13 starting up (core dumps disabled)
dovecot: ssl-params: Generating SSL parameters
postfix/master[9917]: daemon started -- version 2.8.5, configuration /etc/postfix
dovecot: ssl-params: SSL parameters regeneration completed
postfix/master[9917]: terminating on signal 15
postfix/master[10196]: daemon started -- version 2.8.5, configuration /etc/postfix
dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
dovecot: config: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
postfix/master[2435]: daemon started -- version 2.8.5, configuration /etc/postfix
postfix/master[2435]: terminating on signal 15
postfix/master[2965]: daemon started -- version 2.8.5, configuration /etc/postfix

Best Answer

The tutorial is from May 9th, 2010.
v1.2.6 2009-10-05 The last dovecot version before that date
v2.0.rc1 2010-07-02 The next dovecot version after that date

So the tutorial probably will use a 1.x configuration, while nowadays we will use dovecot 2.x. Well and A LOT has changed in how the configuration is set since then.

Now I found this http://wiki2.dovecot.org/Upgrading/2.0
Next to some other info, it provides a way to convert the config from 1.2 to 2.0.

Here's even more about upgrading http://wiki2.dovecot.org/Upgrading

I have no solution though (yet)

Edit:

Better solution
Just forget that tuorial from http://library.linode.com and use this up to date much better tutorial
http://www.exratione.com/2012/05/a-mailserver-on-ubuntu-1204-postfix-dovecot-mysql/
It also shows you how to install spam filter, anti virus detection and add more security to your mail server. Also with this solution you'll be able to very easily add multiple domains.
I had the solution below working first, now I switched to that solution and it works and does what I want perfectly.

Question related solution
But if you must exactly find a solution for the dovecot problem like described in the question, here's how I solved the problem...
also install:

apt-get install dovecot-sieve  
apt-get install dovecot-managesieved  
apt-get install dovecot-mysql  

if you like, read the hints on upgrading the old 1.x config http://wiki2.dovecot.org/Upgrading

My dovecot.conf:

log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/home/vmail/%d/%n/Maildir
namespace {
  inbox = yes
  location = 
  prefix = INBOX.
  separator = .
  type = private
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
protocols = imap pop3
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
  unix_listener auth-master {
    mode = 0600
    user = vmail
  }
  user = root
}
ssl_cert = </etc/ssl/certs/dovecot.pem
ssl_key = </etc/ssl/private/dovecot.pem
#userdb {
#  args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
#  driver = static
#}
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
protocol lda {
  auth_socket_path = /var/run/dovecot/auth-master
  log_path = /home/vmail/dovecot-deliver.log
  mail_plugins = sieve
  postmaster_address = postmaster@example.com
  plugin {
    sieve_global_path = /var/vmail/globalsieverc
    # The include extension fetches the :personal scripts from this 
    # directory. When ManageSieve is used, this is also where scripts 
    # are uploaded.

    sieve_dir = ~/sieve

    # The location of the user's active script:

    sieve = ~/.dovecot.sieve

    # Directory for :global include scripts (for v1.1 include extension)

    sieve_global_dir = /var/vmail/sieve

    sieve_maxscriptsize = 128
  }
}
protocol pop3 {
  pop3_uidl_format = %08Xu%08Xv
}

My dovecot-db.conf.ext

driver = mysql
connect = host=127.0.0.1 dbname=mail user=mail_admin password=your_password
default_pass_scheme = CRYPT
#password_query = SELECT email as user, password FROM users WHERE email='%u';
#user_query = SELECT email as user, password, 5000 as uid, 5000 as gid, '/var/vmail/%d/%n' as home FROM view_users WHERE email='%u';
password_query = SELECT email AS user, password, 5000 AS userdb_uid, 5000 AS userdb_gid, '/var/vmail/%d/%n' AS userdb_home FROM users WHERE email = '%u';
user_query = SELECT email AS user, password, 5000 AS uid, 5000 AS gid, '/var/vmail/%d/%n' AS home FROM users WHERE email = '%u';

My /etc/postfix/sasl/smtpd.conf (note the auxprop_plugin:sql, sql_engine:mysql, and the '%u@%r')

pwcheck_method: saslauthd
mech_list: plain login pam
allow_plaintext: true
auxprop_plugin: sql
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: mail_admin
sql_passwd: your_password
sql_database: mail
sql_select: select password from users where email = '%u@%r'

Sources:
I've gathered all infos about this by googling, and don't know where I was everywhere, but the last problem

2013-01-03 16:43:27 lda: Error: userdb lookup(info@example.com): Disconnected unexpectedly
2013-01-03 16:43:27 lda: Fatal: Internal error occurred. Refer to server log for more information.

I solved reading some of http://workaround.org/ispmail/lenny/configure-dovecot
Basically, I found that you get good results when you google whatever error output you get in here:

/home/vmail/dovecot-deliver.log
/var/log/mail.log
/var/log/mail.err
/var/log/syslog