October 2009 Archives

Fri Oct 2 14:53:58 EEST 2009

Qmail's Voodoo spells and magics ! Workarounds to some common problems, QMAIL HELL!

It's one of this days, when you'd wish to be dead and never born ever!
I experienced terrible problems with Qmail once AGAIN!
Most of the qmail administrators out there are probably aware, Everytime qmail stops working it's like
walking in a dark room without a light torch before you fix it up.
To fix a broken qmail your only friend could be patience. It's fucking insane seriously I more and more start hating qmail when it's broken.
I've experienced the following error messages today on our corporate qmail:
delivery xx: failure: Sorry._Although_I'm_listed_as_a_best-preference_MX_or_A_for_that_host,/it_isn't_in_my_control/locals_file,_so_I_don't_treat_it_as_local.

as well as:

delivery 232: deferral: Sorry,_I_wasn't_able_to_establish_an_SMTP_connection._(#4.4.1)/
A lot of this junk filled the qmail logs. I still am not completely sure the exact reasons
what caused the problems. However I fixed the situation tweakening some of the common
qmail and vpopmail configuration files and respectively their cdb files.
Here is the list of files I got to rebuild and the things I've did to resolve the qmail issues:
cd /home/vpopmail/domains;
for i in *; do echo +$i-:$i:89:89:/home/vpopmail/domains/$i:-:: >>assign; done
# backup old assign file just in case something goes wrong
cp -rpf /var/qmail/users/assign /var/qmail/users/assign.bak
mv assign /var/qmail/users/assign

# backup virtualdomains list file
cp -rpf /var/qmail/control/virtualdomains /var/qmail/control/virtualdomains.bak
for i in *; do echo $i:$i >>virtualdomains; done
mv virtualdomains /var/qmail/control/

# Make sure your /var/qmail/control/rcpthosts contains all the vpopmail domains
# backup rcpthosts for laters
cp -rpf /var/qmail/control/rcpthosts /var/qmail/control/rcpthosts.bak
for i in *; do echo $i >>rcpthosts; done
cp -rpf rcpthosts /var/qmail/control/
# backup morercpthosts
cp -rpf morercpthosts /var/qmail/control/morercpthosts.bak
# overwrite the old morercpthosts
# in my case morercpthosts was missing all the vpopmail virtual domains
# thus the domains missing the file wasn't able to receive mail
cp -rpf rcpthosts /var/qmail/control/morercpthosts

# Another problem if you're using qmail check user patch might be in /var/qmail/users/recipients
# Thus rebuilding the recipients file is a good idea.
# Rebuilding it might be done through qmail-vpopmail2recipients script
# the script has a bug the last if statement, where two if's have to be commented to make it wokring
# Below I'll put a link to a working version of the qmail-vpopmail2-recipients script

# Another possible problem could be in /var/qmail/users/cdb
# Therefore it might be a good idea to rebuild it with
/var/qmail/bin/qmail-newu
# Another thing to do is to rebuild the /var/qmail/control/morercpthosts.cdb file with the command
/var/qmail/bin/qmail-newmrh
# Other things I did was
# to assure myself that /var/qmail/control/me contains my mail server host name
# /var/qmail/control/locals should contain "localhost" as well as the FQDN (Fully Qualified Domain Name) (e.g. your domain name)

# Also I checked my /etc/tcp.smtp and assured myself everything is correct there.
# After which I executed
qmailctl cdb
# That rebuilded my /etc/tcp.smtp.cdb file
# Well that was mostly what I did to fix my problems.
# Another think that might be a good idea is to try
cd /home/vpopmail/domains;
for i in *; do /home/vpopmail/bin/vdominfo $i; done
# If you observe some domain's domain info cannot be shown
# then that might be due to some problem with your vpopmail
# It might be a good idea to check your
/var/qmail/bin/qmail-showctl
# qmail-showctl is a handy diagnosis qmail tool
# While looking over the command output
# I had to make sure my cdb files are "Modified Recently"
# and my virtualdomains are all showing up
# THat's mostly what fixed qmail for me
# Next I executed
qmailctl stop; sleep 10; qmailctl start
# that restarted my qmail
# However qmail doesn't always start logging to /var/log/qmail directory right away
# after restart
# SOmetimes the qmail server needs a couple of restarts before it starts serving mail
# Thus restarting it is always full of uncertancies and a lot of broken nerves!
I love qmail it absolutely works brilliant as long as it works, quite often
if you do even minor changes that usually means a broken qmail and qmail hell again!
I truly hope this post could be helpful to somebody out there
Here is a link to a working version of qmail-vpopmail2-recipients

Posted by hip0 | Permanent link

Thu Oct 1 18:09:25 EEST 2009

How to fix problems with encoding not showing umlauts in after import of sql data to MySQL

I'm restoring some websites from backups this days. One of the swiss websites had a serious problem
with umlauts not showing up. This happened right after I've used an old dump from a MySQL Server
running version 4.x, the imported data was to MySQL server version 5. The problem consisted in that
everywhere an umault was placed the shown content was
 ü
. You can imagine how
annoying and ugly that looked, the whole text was crappy. After some googling with a help
of one of my colleagues (a programmer). I was pointed to this nice article
Mysql Latin1 Utf8 Conversion . What happens is that for some reason the dump I've made had latin1 character-set even though the
data inside was in utf8. Thus importing the dump would try to import the data as latin1 and make
a crap out of it.

The fix is as simple as substituting latin8 to utf8 in your mysql dump file and then reimporting it again
.
In my case the browser displayed by default the website characters in iso8859 instead of utf8, so I had
to specificly to change the browser encoding to UTF8 to realize all is okay. Then it was necessery to
modify all the templates to use UTF8 instead of the wrong character encoding. I have no clue
how does it happened that the same umlaut encoding on the old server, what I suspect is there
was something with the Apache's default character encoding probably I have it set there by default
set to utf8. Well so far so good, let's see how much trashy stuff I have to deal with today.

Posted by hip0 | Permanent link