We help IT Professionals succeed at work.

Postfix / Courier / MySQL cannot send email

I am using Slackware 10.2 using the default 2.4.31 kernel.

I have postfix 2.3 and courier-imap and courier-pop3  and MySQL 5.0 setup and working.  I can currently receive emails with no problems.

I cannot send emails with postfix when i connect directly to my mail server.  I also have other users who will be connecting to attempt to recv and send emails.  So there is no 1 domains or subnet to put in the /etc/postfix/main.cf file.  I need to be able to use SMTP-AUTH to be able to authenticate and send email.

# postconf -a

comes back with


... I have downloaded and installed dovecot 1.0.10 but cannot get dovecot to run. I get the following error:

# dovecot

Error: Login user doesn't exist: dovecot
Fatal: Invalid configuration in /usr/local/etc/dovecot.conf

Here is my /usr/local/etc/dovecot.conf file

---- /usr/local/etc/dovecot.conf ----
auth default {
        mechanisms = plain login
        passdb sql {
                args = /usr/local/etc/dovecot-sql.conf
        userdb static {
                args = uid=2001 gid=1001 home=/usr/local/vmail/%d/%n
        socket listen {
                client {
                        path = /var/spool/postfix/private/auth
                        mode = 0660
                        user = postfix
                        group = postfix
---- EOF /usr/local/etc/dovecot.conf ----

If there is more information needed, please let me know.  

I don't have to use DOVECOT but the setup i have can receive email and that took me a while to get setup and working with MySQL and would prefer to not have to change from courier to dovecot but if need be, i will do it.

Thanks for any help!
Watch Question

Pétur Ingi EgilssonSoftware Engineer -- Consultant

dovecot wants to run on it's own username\password
create a username : dovecot
create a group: dovecot

then : useradd -d /var/run/dovecot -s /bin/false -g dovecot -M -r -u 96 dovecot


the useradd statement didn't work, it said -r was an invalid option.

I manually created the user in /etc/passwd and the group in /etc/group and now when i try to execute dovecot it says:

Error: Can't use SSL certificate /etc/ssl/certs/dovecot.pem: No such file or directory


ok, here's an update. I created the certificates and put them in the directory where dovecot wants them but now when i run dovecot, i get the following message.

Fatal: listen(143) failed: Address already in use

This is telling me that it's trying to bind to port 143 which is the IMAP port. I understand that, but i am using courier as my imap and pop3 daemon's and need to make it so dovecot is used to just authenticate via SMTP_AUTH.

Let me know if you need more information.
Ok i got everything figured out.  Here is the solution.

I started off with my original problem which got me further once i created the dovecot user and group.

then i had to do

openssl genrsa -des3 -out dovecot.pem in the /etc/ssl/certs and the /etc/ssl/private directories.

once that was complete i had to recompile dovecot to support mysql which isn't supported by default in the dovecot-1.0.10 version.

untar the dovecot package, the run

./configure --with-mysql
make install

this will install dovecot with mysql support.  You can double check this by running the following:

dovecot --build-options

if it comes back in the passdb and userdb lines with sql or mysql then you should be good to go! run dovecot from the command line and everything should start up just fine.

NOTE: before you run dovecot, if you are going to be using dovecot to be just for SMTP_AUTH for postfix, you must be sure to add the line "protocols = none" to your dovecot.conf file otherwise it will attempt to be your imap and pop3 daemons / servers.  In my specific case, i did not want that since i was already running courier as my imap and pop3d servers.

you can verify this by looking in the /var/log/messages file.  

then i had to edit my /etc/postfix/main.cf file and add the following lines:

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

once this was added, i had to setup my dovecot-sql.conf file.

---- /usr/local/etc/dovecot-sql.conf ----
driver = mysql
connect = host=<path/to/mysql.sock> user=<dbusername> password=<dbpasswd> dbname=<mysqldb>
default_pass_scheme = PLAIN
password_query = SELECT password FROM <mysqldbname> WHERE email = '%u'
---- EOF /usr/local/etc/dovecot-sql.conf ----

at first in the password_query section i didn't have SELECT password because i had the passwd in a different field.  Dovecot requires that it comes back as the "PASSWORD" field.  I originally had my passwords in a field called clear.  To prevent me having to reinvent the wheel i just created an additional field called password and duplicated the password entry from the "clear" field to the "password" field.

Hope this helps anyone else that may be having a problem.  There wasn't any one place that had all this information in one place.
Pétur Ingi EgilssonSoftware Engineer -- Consultant

the useradd statement didn't work, it said -r was an invalid option.
sorry, it was supposed to be a big -R

Closed, 500 points refunded.
EE Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.