# Power failed - Qmail corrupted.  What next? [closed]

## TheNewb

Well, other knocks at my inexperience with file systems aside, I am trying to get the email services back online.

Running qmail, vpopmail, courrier-imap. 

This morning when power failed, after the file system check all email services were rejected.  No user accoutns showed in qmail admin, and all attempts to connect are rejected.

All the data in /var/vpopmail/domains/ iseems to be intact, valias still lists proper aliases.

I've done a search on recovering the system, but I can't find any good documents... where do I start?

----------

## TheNewb

I re-emerged qmail, vpopmail, courior-imap and that fixed the email accoutns not showing up...

But no one can log in in imap or pop3..  Unknown if outgoing mail is down...  Any helps where to go?

----------

## Rüpel

are the ports open? (netstat -tuanp)

what do the logfiles tell you?

----------

## TheNewb

The ports are still open...  

/var/log/qmail/qmail-smtpd/current shows that incomming emails are still being processed properly..

I don't know where to find a more detailed log for pop3/imap, /var/log/messages has lines like these:

```

Feb 15 00:14:23 server imapd: LOGIN FAILED, user=postmaster@domain.com, ip=[::ffff:127.0.0.1]

Feb 15 00:14:28 server imapd: LOGOUT, ip=[::ffff:127.0.0.1]

Feb 15 00:14:42 server pop3d: Connection, ip=[::ffff:192.167.1.135]

Feb 15 00:14:46 server pop3d: LOGIN FAILED, user=user@domain.com, ip=[::ffff:192.167.1.135]

```

IMAP clients say invalid user or password, pop3 just says Login Failed..

qmail-admin now correctly shows the users and their space usage.  

At least I know SOME of it is working back there..

----------

## clintar

If you are using mysql for keeping the vpopmail login info, which would be the case if you followed the howto, then you should probably try to repair your mysql tables.  Not sure where to look to tell which would be corrupted at the moment, but you would run as root

```
# mysql -p

mysql> select database vpopmail;

mysql> use vpopmail;

mysql> repair table vlog;

```

That's just an example.   There's also the tables dirlog, lastauth, limits, relay, valias, and vpopmail.  Might just want to run the repair on all of them.  Hope it helps.

----------

## TheNewb

Checking the database was on my list of initial things I did...  Although I hadn't thought of rebuilding the tables since the browsing of them worked okay.

Rebuilt all the tables..  also recompiled checkpassword cmd5checkpw queue-fix dot-forward and daemontools, and still don't have any luck...  Arrrgh...

----------

## clintar

Make sure to recompile courier-authlib after vpopmail gets updated, FYI.  Don't know if that falls in line with what you're seeing, but it's bitten me a few times.

----------

## TheNewb

Tried rebuilding courier-authlib a couple times... tried it again for good measure!  (Trying everything I can!)

I tested if outgoing email is functioning, and it isn't.  I can send a email to locations ON the server, but a valid recipient from the email server gets the following error: 

```
Sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1). Please verify that your email address is correct in your Mail Preferences and try again. 
```

----------

## TheNewb

Okay, NOW I've found a meaningful error and am not shooting as much in the dark.  

I modified /etc/courier/authlib/authdaemonrc and changed debug login to 1 instead of zero,

Tried to collect a message and found this in /var/log/messages:

```
Feb 20 10:23:03 richie pop3d: Connection, ip=[::ffff:192.168.1.135]

Feb 20 10:23:09 richie authdaemond: received auth request, service=pop3, authtype=login

Feb 20 10:23:09 richie authdaemond: FAIL, all modules rejected

Feb 20 10:23:09 richie pop3d: LOGIN FAILED, user=user@domain.com, ip=[::ffff:192.168.1.135]

Feb 20 10:23:16 richie pop3d: Disconnected, ip=[::ffff:192.168.1.135]
```

----------

## clintar

I'd do the check in code listing 3.3 and see what that returns.  Maybe it's a permissions issue that needs to be fixed as in listing 3.2.  I'd at least go over the vpopmail/auth stuff in that howto to make sure things look right.

http://www.gentoo.org/doc/en/qmail-howto.xml

----------

## TheNewb

Gone over everything in the permissions, and it's working as far as the command line goes.  The permissions list okay, the text-hit to try and log in logs a successful log in... but it's still not working.

This might be related, but outgoing email no longer functions as well.  It's telling clients that the recipient is invalid or something...

----------

## TheNewb

Is there any way I can find out what modules authdeamon is using?  that might give me some clue where to look for more info.  I'm suspecting a config file is damaged somewhere, as I've recompiled as much as I can think of..  I still can't figure out what I'm missing.

----------

## kands

I've had systems go down like yours and it can range from no problem to disasterous depending what is happening on the system when it goes down.  Have you done any filesystem integrity checks?  You may want to do that before you proceed to ensure that nothing is wrong at a low level.  This can often detect corrupt files etc.

----------

## clintar

That howto goes over the courier-authdaemon config files and what goes in them.  Check those.

----------

## TheNewb

I found a problem hidden away in /etc/courier/authlib/authdaemonrc ...  

So now all the users are able to log in and collect their old emails that have been building up.  But in that same stroke, I think I broke something else.  Now ALL incomming emails are bounced saying no such mail box,  and no one can send outgoing mail.  The outgoing messages give this error (On pop3, Imap gives no error):

```
Sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1). Please verify that your email address is correct in your Mail Preferences and try again.  
```

What did I break?  Where do I look to fix it?

----------

## clintar

First thing I'd check is rcpthosts in /var/qmail/control.

----------

## TheNewb

Checking /var/qmail/control for anything goofy in rcpthosts, I noticed some extra .lock files including rcpthosts.lock.

I moved them to a temp-trash folder and it's now accepting email connections and processing emails.  But EVERYTHING is being bounced.  Like there's no email accoutns at all... qmailadmin shows all accoutns and forwards intact.  

The code at 2.5 on http://www.gentoo.org/doc/en/qmail-howto.xml for using qmail-inject does work... but incomming emails all get bounced.

Although it gets even messier if the email is from one user to another user on the same server...

Here's from /var/log/qmail-send/current:

```

@400000004405dc14109ecc84 new msg 7782498

@400000004405dc14109fe9ac info msg 7782498: bytes 599 from <user1@domain.com> qp 16093 uid 201

@400000004405dc1410d90aac starting delivery 1: msg 7782498 to local user2@domain.com

@400000004405dc1410d91664 status: local 1/10 remote 0/20

@400000004405dc1410d91a4c delivery 1: failure: Sorry,_no_mailbox_here_by_that_name._(#5.1.1)/

@400000004405dc1410d91e34 status: local 0/10 remote 0/20

@400000004405dc1410e32884 bounce msg 7782498 qp 16096

@400000004405dc1410e32c6c end msg 7782498

@400000004405dc1410e9eee4 new msg 7782899

@400000004405dc1410e9f2cc info msg 7782899: bytes 1176 from <> qp 16096 uid 206

@400000004405dc14114f82cc starting delivery 2: msg 7782899 to local user1@domain.com

@400000004405dc14114f8e84 status: local 1/10 remote 0/20

@400000004405dc14114f926c delivery 2: failure: Sorry,_no_mailbox_here_by_that_name._(#5.1.1)/

@400000004405dc14114f9654 status: local 0/10 remote 0/20

@400000004405dc141155cc2c bounce msg 7782899 qp 16099

@400000004405dc141155d014 end msg 7782899

```

On a side note...  As frustrated as I am over all this..  I just wanted to make sure I said thank you, all of you...  

Hopefully, I'm learning a lot!

----------

## clintar

Check in /var/qmail/control/conf-smtpd

for

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

and also check section 2.6 and 2.7 for what goes in those files.  One note though, in 2.7, i had to have domain.com instead of mail.domain.com in rcpthosts for it to work for us.

----------

## TheNewb

Hmmm...  

Since I have a liscense to VMware, I decided to try installing qmail on a guest copy of Gentoo (A whole other set of issues on that, but I found my way through them.), and figure out when it's working with the default configuration, compare config files and see what's broken.

Good plan... but when I finally finished getting qmail installed, the guest-OS is doing the exact same thing...  Refusing to deliver mail to valid mail boxes.  

It IS delivering mail to users with a valid .maildir in their home directory, but NOT for users who have accoutns in vpopmail/qmailadmin...  

Both versions are doing exactly the same thing now so my original issue of the server corruption has I think been solved.

Now I have to figure out why it's not working.   Eeeek!   Hopefully there's something about this in another post...

----------

## PaveQ

UPS, backup?   :Shocked: 

----------

## TheNewb

Wasn't before...  there is now you bet ya!

----------

## TheNewb

Since the original post was about solving corruption... and now the problem is a vpop mail failure on a default installation... I'm going to consider this thread closed and start a new one for the new issue...

----------

