# The mailserver from Hell [Solved]

## Wolven

Greetings! I have been batteling with my mailserver for some days and nights now and I'm at the end of my rope and sanity. Please help me out of this mess.

I've setup a mailserver after the 'qmail/vpopmail Virtual Mail Hosting System Guide'. It has been working nicly for several months, but I've screwed it up after doing 'emerge -uD world' and trying to fix the permission problems with qmail-scanner and ClamAV.

I've been reading lots of post and I've been trying lots of different things to get it back to a working condition, but I can't for the life of me get it to recieve mail. I'm now so confused that I don't quite know where to start, but I'll try to give as much information as possible.

I can send mail to external adresses, but I can't receive any mail. Not from adresses on my domain or from other external adresses.

I know there has been an upgrade to courier-imap and that there has been some changes. I think I've got that sorted out, but I'm not shure.

Anyway. Here are the errors from my logs:

File: /var/log/mail/current ( Here is the entire log: link removed )

```

Mar  9 09:33:12 [imapd-ssl] Failed to create cache file: maildirwatch (someotherlooser@ionbox.org)

Mar  9 09:33:12 [imapd-ssl] Error: Input/output error

Mar  9 09:33:12 [imapd-ssl] Check for proper operation and configuration

Mar  9 09:33:12 [imapd-ssl] of the File Access Monitor daemon (famd).

Mar  9 09:33:15 [imapd-ssl] DISCONNECTED, user=someotherlooser@ionbox.org, ip=[192.168.0.197], headers=0, body=0, time=5, starttls=1

Mar  9 09:39:36 [imapd-ssl] Connection, ip=[192.168.0.197]

Mar  9 09:39:36 [imapd-ssl] LOGIN, user=somelooser@ionbox.org, ip=[192.168.0.197], protocol=IMAP

Mar  9 09:40:03 [imapd-ssl] Connection, ip=[192.168.0.197]

Mar  9 09:40:03 [imapd-ssl] LOGIN, user=someotherlooser@ionbox.org, ip=[192.168.0.197], protocol=IMAP

Mar  9 09:40:03 [imapd-ssl] quota string '52428800' not parseable

Mar  9 09:50:06 [imapd-ssl] Connection, ip=[192.168.0.197]

Mar  9 09:50:06 [imapd-ssl] LOGIN, user=someotherlooser@ionbox.org, ip=[192.168.0.197], protocol=IMAP

Mar  9 09:50:06 [imapd-ssl] quota string '52428800' not parseable

Mar  9 09:54:18 [imapd-ssl] Connection, ip=[192.168.0.197]

Mar  9 09:54:18 [imapd-ssl] LOGIN, user=somelooser@ionbox.org, ip=[192.168.0.197], protocol=IMAP

Mar  9 09:54:20 [imapd-ssl] quota string '52428800' not parseable

                - Last output repeated 16 times -

Mar  9 09:56:49 [imapd-ssl] DISCONNECTED, user=somelooser@ionbox.org, ip=[192.168.0.197], headers=0, body=0, time=1033, starttls=1

Mar  9 09:56:49 [imapd-ssl] DISCONNECTED, user=someotherlooser@ionbox.org, ip=[192.168.0.197], headers=0, body=0, time=1006, starttls=1

Mar  9 09:56:49 [imapd-ssl] DISCONNECTED, user=someotherlooser@ionbox.org, ip=[192.168.0.197], headers=0, body=0, time=403, starttls=1

Mar  9 09:56:49 [imapd-ssl] DISCONNECTED, user=somelooser@ionbox.org, ip=[192.168.0.197], headers=0, body=0, time=151, starttls=1

Mar  9 09:56:56 [imapd-ssl] Connection, ip=[192.168.0.197]

Mar  9 09:56:56 [imapd-ssl] LOGIN, user=somelooser@ionbox.org, ip=[192.168.0.197], protocol=IMAP

Mar  9 09:57:02 [imapd-ssl] DISCONNECTED, user=somelooser@ionbox.org, ip=[192.168.0.197], headers=0, body=0, time=6, starttls=1

Mar  9 09:59:18 [imapd-ssl] Connection, ip=[192.168.0.197]

Mar  9 09:59:18 [imapd-ssl] LOGIN, user=somelooser@ionbox.org, ip=[192.168.0.197], protocol=IMAP

Mar  9 09:59:22 [imapd-ssl] DISCONNECTED, user=somelooser@ionbox.org, ip=[192.168.0.197], headers=0, body=0, time=4, starttls=1

Mar  9 13:48:37 [spamc] connect(AF_INET) to spamd at 127.0.0.1 failed, retrying (#1 of 3): Connection refused

Mar  9 13:48:38 [spamc] connect(AF_INET) to spamd at 127.0.0.1 failed, retrying (#2 of 3): Connection refused

Mar  9 13:48:39 [spamc] connect(AF_INET) to spamd at 127.0.0.1 failed, retrying (#3 of 3): Connection refused

Mar  9 13:48:40 [spamc] connection attempt to spamd aborted after 3 retries

Mar  9 20:18:33 [imapd-ssl] Connection, ip=[192.168.0.197]

Mar  9 20:18:34 [imapd-ssl] LOGIN, user=somelooser@ionbox.org, ip=[192.168.0.197], protocol=IMAP

Mar  9 20:18:36 [imapd-ssl] DISCONNECTED, user=somelooser@ionbox.org, ip=[192.168.0.197], headers=0, body=0, time=2, starttls=1

```

 File: /var/log/qmail/qmail-send/current ( Here is the entire log: link removed )

```

@40000000422f4a961c402b8c starting delivery 87: msg 7807671 to remote someotherlooser@ionbox.org

@40000000422f4a961c4042fc status: local 0/10 remote 1/20

@40000000422f4a9630702774 delivery 87: deferral: Sorry,_I_wasn't_able_to_establish_an_SMTP_connection._(#4.4.1)/

@40000000422f4a96307042cc status: local 0/10 remote 0/20

```

Here are my config files:

File: /etc/tcp.smtp

```

# ALLOW THESE IPS TO RELAY MAIL THROUGH OUR SERVER

#

# Local class-c's from our LAN are allowed to relay,

# and we wont bother doing any RBL checking.

#123.123.123.:allow,RELAYCLIENT="",RBLSMTPD=""

#123.111.111.:allow,RELAYCLIENT="",RBLSMTPD=""

#

# Connections from localhost are allowed to relay

# (because the WebMail server runs on localhost),

# and obviously there is no point trying to perform an RBL check.

127.0.0.1:allow,RELAYCLIENT="",RBLSMTPD=""

192.168.0.:allow,RELAYCLIENT="",RBLSMTPD=""

#192.168.1.:allow,RELAYCLIENT="",RBLSMTPD=""

#

#-----------------------------------------------------------------

# ALLOW EVERYONE ELSE TO SEND US MAIL

#

# Everyone else can make connections to our server,

# but not allowed to relay

# RBL lookups are performed

#:allow

# If you are using qmail-scanner, this line here is the correct one to use

# instead (comment out the above ':allow' line FIRST) and applies that script

# to any mail coming in that is not from a host allowed to relay. You can

# change the value of the variable to any other value you desire to use custom

# scripts for example.

:allow,QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue"

```

/var/qmail/control/

```

# hostname --fqdn

ion.ionbox.org

 # cat me 

ion.ionbox.org

# cat defaultdomain 

ionbox.org

# cat plusdomain    

ionbox.org

# cat locals     

ion.ionbox.org

# cat rcpthosts

ionbox.org

```

I have renamed authdaemon in /etc/init.d/ to authdaemond.old and I've configured authdaemonrc in /etc/courier/authlib/ to:

```

authmodulelist="authvchkpw"

```

(I've tried to auth against mysql, but I could not get that working.)

And I've issued:

```
# /etc/init.d/courier-authlib restart

 * Stopping courier-imapd over SSL...                                     [ ok ]

 * Stopping courier-pop3d over SSL...                                     [ ok ]

 * Stopping courier-authlib: authdaemond...                               [ ok ]

 * Starting courier-authlib: authdaemond...                               [ ok ]

 * Starting courier-imapd over SSL...                                     [ ok ]

 * Starting courier-pop3d over SSL...                                     [ ok ]

```

File: /var/qmail/control/conf-smtpd

```

QMAIL_SMTP_AUTHHOST=$(<${QMAIL_CONTROLDIR}/me)

[ -z "${QMAIL_SMTP_POST}" ] && QMAIL_SMTP_POST=/bin/true

QMAIL_SMTP_CHECKPASSWORD="/var/vpopmail/bin/vchkpw"

QMAIL_SMTP_POST="${QMAIL_SMTP_AUTHHOST} ${QMAIL_SMTP_CHECKPASSWORD} ${QMAIL_SMTP_POST}"

```

The rest of the config files is as far as I know like described in the guide.

I hope I've included the relevant information here, but if I haven't please let me now and I'll provide it.Last edited by Wolven on Fri Mar 11, 2005 12:55 am; edited 2 times in total

----------

## MrWolf

You may find you will get some extra information with the log files found under /var/log/qmail !

----------

## Wolven

The only other log I have under /var/log/qmail/ is /var/log/qmail/qmail-smtpd/current

Here is the contend of that file

```

@40000000422eb21a0924a12c X-Qmail-Scanner-1.25st:[ion111035649669418880] clamdscan: corrupt or unknown clamd scanner error or memory/resource/perms problem - exit status 512/2

@40000000422eb2912a4069f4 X-Qmail-Scanner-1.25st:[ion111035661569418886] clamdscan: corrupt or unknown clamd scanner error or memory/resource/perms problem - exit status 512/2

@40000000422eb34c18643d64 X-Qmail-Scanner-1.25st:[ion111035680269418898] clamdscan: corrupt or unknown clamd scanner error or memory/resource/perms problem - exit status 512/2

@40000000422eb3f8176fcb44 X-Qmail-Scanner-1.25st:[ion111035697469418918] clamdscan: corrupt or unknown clamd scanner error or memory/resource/perms problem - exit status 512/2

@40000000422eb6542676c37c X-Qmail-Scanner-1.25st:[ion11103575786947630] clamdscan: corrupt or unknown clamd scanner error or memory/resource/perms problem - exit status 512/2

@40000000422eb66d1d67d30c X-Qmail-Scanner-1.25st:[ion11103576036947650] clamdscan: corrupt or unknown clamd scanner error or memory/resource/perms problem - exit status 512/2

```

Nice nick BTW.  :Wink: 

----------

## SerfurJ

i have the same problem.  it doesn't look good.. see this thread:

http://www.linuxforums.org/forum/topic-33541.html

----------

## SerfurJ

https://forums.gentoo.org/viewtopic-t-291738-highlight-courierauthlib.html

----------

## Wolven

 *SerfurJ wrote:*   

> https://forums.gentoo.org/viewtopic-t-291738-highlight-courierauthlib.html

 

I have read this post already. It's this post that made me realise that 'authdaemonrc' should now be in /etc/courier/authlib. I've never had courier-imap auth against mysql before, so I did not have a 'authmysqlrc' to move. I tried to set it up though, but I could not login to my account with imap/pop3. My 'authmysqlrc' is probably configured wrong, it looks like this:

```

##VERSION: $Id: authmysqlrc,v 1.17 2004/04/20 01:38:17 mrsam Exp $

#

# Copyright 2000-2004 Double Precision, Inc.  See COPYING for

# distribution information.

#

# Do not alter lines that begin with ##, they are used when upgrading

# this configuration.

#

# authmysqlrc created from authmysqlrc.dist by sysconftool

#

# DO NOT INSTALL THIS FILE with world read permissions.  This file

# might contain the MySQL admin password!

#

# Each line in this file must follow the following format:

#

# field[spaces|tabs]value

#

# That is, the name of the field, followed by spaces or tabs, followed by

# field value.  Trailing spaces are prohibited.

##NAME: LOCATION:0

#

# The server name, userid, and password used to log in.

MYSQL_SERVER      localhost

MYSQL_USERNAME      root

MYSQL_PASSWORD      $password

##NAME: MYSQL_SOCKET:0

#

# MYSQL_SOCKET can be used with MySQL version 3.22 or later, it specifies the

# filesystem pipe used for the connection

#

# MYSQL_SOCKET      /var/mysql/mysql.sock

##NAME: MYSQL_PORT:0

#

# MYSQL_PORT can be used with MySQL version 3.22 or later to specify a port to

# connect to.

MYSQL_PORT      0

##NAME: MYSQL_OPT:0

#

# Leave MYSQL_OPT as 0, unless you know what you're doing.

MYSQL_OPT      0

##NAME: MYSQL_DATABASE:0

#

# The name of the MySQL database we will open:

MYSQL_DATABASE      vpopmail

##NAME: MYSQL_USER_TABLE:0

#

# The name of the table containing your user data.  See README.authmysqlrc

# for the required fields in this table.

MYSQL_USER_TABLE   users

##NAME: MYSQL_CRYPT_PWFIELD:0

#

# Either MYSQL_CRYPT_PWFIELD or MYSQL_CLEAR_PWFIELD must be defined.  Both

# are OK too. crypted passwords go into MYSQL_CRYPT_PWFIELD, cleartext

# passwords go into MYSQL_CLEAR_PWFIELD.  Cleartext passwords allow

# CRAM-MD5 authentication to be implemented.

#MYSQL_CRYPT_PWFIELD   crypt

##NAME: MYSQL_CLEAR_PWFIELD:0

#

#

MYSQL_CLEAR_PWFIELD   clear

##NAME: MYSQL_DEFAULT_DOMAIN:0

#

# If DEFAULT_DOMAIN is defined, and someone tries to log in as 'user',

# we will look up 'user@DEFAULT_DOMAIN' instead.

#

#

# DEFAULT_DOMAIN      example.com

##NAME: MYSQL_UID_FIELD:0

#

# Other fields in the mysql table:

#

# MYSQL_UID_FIELD - contains the numerical userid of the account

#

MYSQL_UID_FIELD      uid

##NAME: MYSQL_GID_FIELD:0

#

# Numerical groupid of the account

MYSQL_GID_FIELD      gid

##NAME: MYSQL_LOGIN_FIELD:0

#

# The login id, default is id.  Basically the query is:

#

#  SELECT MYSQL_UID_FIELD, MYSQL_GID_FIELD, ... WHERE id='loginid'

#

MYSQL_LOGIN_FIELD   email

##NAME: MYSQL_HOME_FIELD:0

#

MYSQL_HOME_FIELD   homedir

##NAME: MYSQL_NAME_FIELD:0

#

# The user's name (optional)

MYSQL_NAME_FIELD   name

##NAME: MYSQL_MAILDIR_FIELD:0

#

# This is an optional field, and can be used to specify an arbitrary

# location of the maildir for the account, which normally defaults to

# $HOME/Maildir (where $HOME is read from MYSQL_HOME_FIELD).

#

# You still need to provide a MYSQL_HOME_FIELD, even if you uncomment this

# out.

#

MYSQL_MAILDIR_FIELD   maildir

##NAME: MYSQL_DEFAULTDELIVERY:0

#

# Courier mail server only: optional field specifies custom mail delivery

# instructions for this account (if defined) -- essentially overrides

# DEFAULTDELIVERY from ${sysconfdir}/courierd

#

# MYSQL_DEFAULTDELIVERY defaultdelivery

##NAME: MYSQL_QUOTA_FIELD:0

#

# Define MYSQL_QUOTA_FIELD to be the name of the field that can optionally

# specify a maildir quota.  See README.maildirquota for more information 

#

# MYSQL_QUOTA_FIELD   quota

##NAME: MYSQL_AUXOPTIONS:0

#

# Auxiliary options.  The MYSQL_AUXOPTIONS field should be a char field that

# contains a single string consisting of comma-separated "ATTRIBUTE=NAME"

# pairs.  These names are additional attributes that define various per-account

# "options", as given in INSTALL's description of the "Account OPTIONS"

# setting.

#

# MYSQL_AUXOPTIONS_FIELD   auxoptions

#

# You might want to try something like this, if you'd like to use a bunch

# of individual fields, instead of a single text blob:

#

# MYSQL_AUXOPTIONS_FIELD   CONCAT("disableimap=",disableimap,",disablepop3=",disablepop3,",disablewebmail=",disablewebmail,",sharedgroup=",sharedgroup)

#

# This will let you define fields called "disableimap", etc, with the end result

# being something that the OPTIONS parser understands.

##NAME: MYSQL_WHERE_CLAUSE:0

#

# This is optional, MYSQL_WHERE_CLAUSE can be basically set to an arbitrary

# fixed string that is appended to the WHERE clause of our query

#

# MYSQL_WHERE_CLAUSE   server='mailhost.example.com'

##NAME: MYSQL_SELECT_CLAUSE:0

#

# (EXPERIMENTAL)

# This is optional, MYSQL_SELECT_CLAUSE can be set when you have a database,

# which is structuraly different from proposed. The fixed string will

# be used to do a SELECT operation on database, which should return fields

# in order specified bellow:

#

# username, cryptpw, clearpw, uid, gid, home, maildir, quota, fullname, options

#

# The username field should include the domain (see example below).

#

# Enabling this option causes ignorance of any other field-related

# options, excluding default domain.

#

# There are two variables, which you can use. Substitution will be made

# for them, so you can put entered username (local part) and domain name

# in the right place of your query. These variables are:

#       $(local_part), $(domain), $(service)

#

# If a $(domain) is empty (not given by the remote user) the default domain

# name is used in its place.

#

# $(service) will expand out to the service being authenticated: imap, imaps,

# pop3 or pop3s.  Courier mail server only: service will also expand out to

# "courier", when searching for local mail account's location.  In this case,

# if the "maildir" field is not empty it will be used in place of

# DEFAULTDELIVERY.  Courier mail server will also use esmtp when doing

# authenticated ESMTP.

#

# This example is a little bit modified adaptation of vmail-sql

# database scheme:

#

# MYSQL_SELECT_CLAUSE   SELECT CONCAT(popbox.local_part, '@', popbox.domain_name),         \

#         CONCAT('{MD5}', popbox.password_hash),      \

#         popbox.clearpw,               \

#         domain.uid,               \

#         domain.gid,               \

#         CONCAT(domain.path, '/', popbox.mbox_name),   \

#         '',                  \

#         domain.quota,               \

#         '',                  \

#         CONCAT("disableimap=",disableimap,",disablepop3=",    \

#                              disablepop3,",disablewebmail=",disablewebmail, \

#                              ",sharedgroup=",sharedgroup)             \

#         FROM popbox, domain            \

#         WHERE popbox.local_part = '$(local_part)'   \

#         AND popbox.domain_name = '$(domain)'      \

#         AND popbox.domain_name = domain.domain_name

##NAME: MYSQL_ENUMERATE_CLAUSE:0

#

# {EXPERIMENTAL}

# Optional custom SQL query used to enumerate accounts for authenumerate,

# in order to compile a list of accounts for shared folders.  The query

# should return the following fields: name, uid, gid, homedir, maildir

#

# Example:

# MYSQL_ENUMERATE_CLAUSE   SELECT CONCAT(popbox.local_part, '@', popbox.domain_name),         \

#         domain.uid,               \

#         domain.gid,               \

#         CONCAT(domain.path, '/', popbox.mbox_name),   \

#         ''                  \

#         FROM popbox, domain            \

#         WHERE popbox.local_part = '$(local_part)'   \

#         AND popbox.domain_name = '$(domain)'      \

#         AND popbox.domain_name = domain.domain_name

##NAME: MYSQL_CHPASS_CLAUSE:0

#

# (EXPERIMENTAL)

# This is optional, MYSQL_CHPASS_CLAUSE can be set when you have a database,

# which is structuraly different from proposed. The fixed string will

# be used to do an UPDATE operation on database. In other words, it is

# used, when changing password.

#

# There are four variables, which you can use. Substitution will be made

# for them, so you can put entered username (local part) and domain name

# in the right place of your query. There variables are:

#    $(local_part) , $(domain) , $(newpass) , $(newpass_crypt)

#

# If a $(domain) is empty (not given by the remote user) the default domain

# name is used in its place.

# $(newpass) contains plain password

# $(newpass_crypt) contains its crypted form

#

# MYSQL_CHPASS_CLAUSE   UPDATE   popbox               \

#         SET   clearpw='$(newpass)',         \

#            password_hash='$(newpass_crypt)'   \

#         WHERE   local_part='$(local_part)'      \

#         AND   domain_name='$(domain)'

#

```

For the  MYSQL_USERNAME variable I've tried to use both 'root' and 'vpopmail' as usernames. I'm not shure witch username to use here. In my mysql database I have only three users. root, vpopmail and horde.

Mabye I should try to downgrade courier-imap to see if that helps. It's been a while since I've downgraded any pagage, so I need to search on how to do this first because i've forgotten.

----------

## SerfurJ

you need to coerce courier-authlib to run instead of authdaemond.  search the forums for "courier-authlib" and you've find dozens of threads on it.

----------

## Wolven

Thank you for the suggestion, but I've already got courier-authlib running instead of authdaemon

 *Wolven wrote:*   

> 
> 
> I have renamed authdaemon in /etc/init.d/ to authdaemond.old and I've configured authdaemonrc in /etc/courier/authlib/ to:
> 
> ```
> ...

 

I just downgraded courier-imap to version 3.0.8 and renamed authdaemond.old back to authdaemond, but I still could not recieve any mail, so I upgraded back to version 4.0.1, but now I get this:

```

# /etc/init.d/courier-authlib restart

 * Starting courier-authlib: authdaemond...

/usr/bin/env: /usr/sbin/courierlogger: No such file or directory          [ !! ]

```

This whole ordeal makes me want to download Windows Server 2003 off Bittorent and setup MS Exchange instead...  :Crying or Very sad: 

I'm glad this emailserver is just for my private use and not for some company, because then I would have been fired for shure. Mabye I should just go back to using Hotmail.

EDIT:

I solved the courierlogger problem by re-emerging courier-authlib. Atleast I'm back to square one now...

EDIT2:

Looks like the problem is solved. I've removed and re-emerged most of the packages and then went through the config files yet again. I think the problem was the 'virtualdomains' file in /var/qmail/control/

Thanks for the post trying to help me out. I really appreciate it.

----------

## mariourk

Thanks a lot, you saved my ass...   :Very Happy: 

----------

