Migrating emails in plesk 9.5.X

Los buzones de correo se encuentran en esta ubicación:

cd /var/qmail/mailnames/

Lo primero que debemos hacer es realizar una copia de seguridad de los buzones pertenecientes al dominio:

tar cvf mail.tar ./yourdomain.net

Nos creará en esta misma ubicación el archivo backup comprimido, lo movemos a otra ubicación:

mv ./mail.tar /home/myuser

Ahora que ya tenemos todos sus correos comprimidos, podemos moverlo vía ssh al nuevo servidor, con el comando scp (en los próximos post haré más incapié en él)

Desde el servidor origen ejecutamos:

scp ./domain.tar root@newserver:/tmp/

Despues de hacer esto, creamos las cuentas de correo correspondientes via plesk, con el mismo usuario; y en el nuevo servidor descomprimimos el backup que lo hemos movido previamente al directorio /tmp:

tar xvf mail.tar

y luego sicronizamos con el actual buzón:

rsync -rua /tmp/mail/ /var/qmail/mailnames/yourdomain.net/

Debemos asegurarnos que lo ha copiado al dominio correspondiente y que cuenta con los permisos correctos para que no haya ningún problema.

Podemos comprobar la integridad de los correos, accediendo via webmail y entrando en ellos.

Rebuilding qmail's queue

Sometimes you have to do something too hard, dangerous like delete and create again because we don't know how to solve it.
In my own case, few weeks ago I had a big problem with my qmail's queue and permissions. I have tried apps like qmail-remove, qfixq ... but did't work.
Therefore I rebuid myself all my queue directories infraestructure.

I recommend first of all, check your current queue, permissions and directories infraestructure; or create a copy. You can do that typing following command:

cp -Rp /var/qmail/queue /var/qmail/queue.bak

Deleting and rebuilding the queue:

/etc/init.d/qmail stop
cd /var/qmail/queue
rm -rf info intd local mess remote todo
mkdir mess
for i in `seq 0 22`; do
mkdir -p mess/$i
done
cp -r mess info
cp -r mess intd
cp -r mess local
cp -r mess remote
cp -r mess todo
chmod -R 750 mess todo
chown -R qmailq:qmail mess todo
chmod -R 700 info intd local remote
chown -R qmailq:qmail intd
chown -R qmails:qmail info local remote
/etc/init.d/qmail start



How to connect windows share folder to linux

Currently it's normal create connections between linux and windows to share data, printers... but I usually forget it :s
So..
First: we need to create a share folder into windows system, for example: "shared"
Second: Check our ip or hostname
Third: From linux, mount that partition helping us with samba:
Check that samba is installed and smbfs

mkdir /media/mywindowsfolder
mount -t smbfs -o username=****,password=**** //192.168.X.X/shared /media/mywindowsfolder


I hope don't forget it again... :D

In few days I'll try to show how to connect hosts between linux & windows working under domain AD

Handler queue with qmqtool

We have talked about managing queue with qmhandle, but that only it's possible if you can stop qmail service. In my own case, I wasn't able to stop it (I don't know why) but i found other solution: qmqtool, it's very similar to qmhandle and also it can work with qmail process running.

Instructions:

Download it with wget:

wget http://jeremy.kister.net/code/qmqtool/files/qmqtool-1.14.tgz


untar it and execute configure/make/make install into his own dir.

after that you have just install qmqtool in /usr/local/script/

Check permissions(0700) & owner(root).
Executing show us that menu

qmqtool version 1.14
syntax: qmqtool [-l] [-L] [-R] [-S [-nN]] [-T] [-s] [-Q] [-c] [-r] [-i [-nN]] [-V]
[-E(A|R|L)] [-U(A|R|L)] [-vN [-w]] [-e(N|[-f 'STRING'][-oN])] [-u(N|[-f 'STRING'][-oN])]
[-d(N|[-f 'STRING'][-oN])] [-f 'STRING'] [-oN] [-B(b|r)] [-x(N|[-f 'STRING'][-oN])]

-l list messages in all parts of the queue
-L list messages with local recipients
-R list messages with remote recipients
-T list messages not completely processed
-s show statistical information
-Q be as quiet as possible (useful for snmp, cron, and such)
-V be more verbose
-B
b Backup queue into /var/qmail/queue.backup/
r Restore backup from /var/qmail/queue.backup/
-c check queue consitancy
-r repair queue (by deleting fragments) found by checking queue consistancy
-i show how many messages are queued per ip address
-nN pay attention to the Nth last smtp-hop
-S show how many bytes are queued per ip address
-e expire message
may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
-u unexpire message
may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
-d delete message
may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
-E expire messages in [A]ll, [R]emote, or [L]ocal queues
-U unexpire messages in [A]ll, [R]emote, or [L]ocal queues
-v
N view first 100 lines of message number N
N -w view whole message N
-f 'STRING' display comma separated list of message number(s) containing STRING.
prints 0 if no matches are found.
-o N display comma separated list of message number(s) older than N hours.
prints 0 if no matches are found.
-x N prints extended information on message N. format identical to -l.
may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N

see the FAQ for examples.



For example, if we want delete every mails with a same subject..:

qmqtool -d -f '^Subject: News Hello' => Delete all messages with "News Hello" like Subject

Queue too big in qmail

Sometimes you can have some problems with your mail-server due to a foreign attack, mailbombers and so on... For example, some symptom could be: you can send but never is delivered or you can't receive anything, so first of all we must check mail queue with this command:

/var/qmail/bin/qmail-qstat


may be you will find too much mails in your queue (10000-50000...) anything it isn't working well.
There is a application, qmhandle, very useful that it can help you with that task.

Downloading the qmhandle tarball using wget:

wget http://mesh.dl.sourceforge.net/sourceforge/qmhandle/qmhandle-1.2.0.tar.gz


untar it

tar -zxvf qmhandle-1.2.0.tar.gz


after that, execute it:

./qmhandle


Before use don't forget stop qmail service
and check the menu options:

Available parameters:
-a : try to send queued messages now (qmail must be running)
-l : list message queues
-L : list local message queue
-R : list remote message queue
-s : show some statistics
-mN : display message number N
-dN : delete message number N
-Stext : delete all messages that have/contain text as Subject
-D : delete all messages in the queue (local and remote)
-V : print program version

Additional (optional) parameters:
-c : display colored output
-N : list message numbers only
(to be used either with -l, -L or -R)

You can view/delete multiple message i.e. -d123 -v456 -d567



Of course, before you use any option you must look what is happening, looking for into qmail logs or using the following command to know something more about your big queue:

/var/qmail/bin/qmail-qread

that command show you what mails there are in that queue


If you have just have a critical attack from a sender, for example, you could use -Stext option to delete all mails that contains that text as subject.

After delete all mails from your queue and restore to normal behavior, you must to improve your security.