Worried about email migrations and mail syncing – get getmail for the rescue

Most of the hosting providers offer free server migration. The free website migration started as early as 2005, in the industry. But only a few providers offer the email migration for a website transfer involving different control panels. So using getmail is the easiest way to transfer emails. All we need is to create the email account in the new server and configure the getmail to transfer the emails.

Download getmail at http://pyropus.ca/software/getmail/old-versions/getmail-4.20.3.tar.gz


wget http://pyropus.ca/software/getmail/old-versions/getmail-4.20.3.tar.gz
tar xzf getmail-4.20.3.tar.gz
cd getmail*
python setup.py install

Now you have to create a getmailrc , the getmail configuration file inside the home folder of the user. getmailrc need not be inside the home directory. You have to create the folder .getmail where getmail keeps a log of the emails retrieved based on each configuration file you may have.You can have multiple destination and retriever sections in one single getmailrc as well.

I must say getmail is so much flexible and rightly coded when the mailsync or imapsync didn’t do their job right or up to the mark. And is an excellent replacement for fetchmail. It supports POP, POP3S, IMAP4 and IMAPS, and also can store the mails retrieved in mbox or maildir format at the destination.

An extremely simple getmailrc file will look like this

[retriever]
type = SimpleIMAPRetriever
server = mail.domain.com
username = direct@domain.com
password = direct

[destination]
type = Maildir
path = /home/cpusername/mail/.direct@domain_com/

The file format should be pretty self-explanatory. You’re telling getmail to fetch your email from server, mail.domain.com by logging to it using the mentioned username and password. The destination section mentions where to store the retrieved email and in which format (Maildir or mbox or mboxrd). Make sure that the cur, new and tmp are there inside those folder though. However getmail may create those folders automatically though.

Finally to get this going, just run “getmail –rcfile getmailrc”

Once you run it, assuming that the getmailrc is properly configured, you will be welcomed by a below output.

getmail version 4.20.3
Copyright (C) 1998-2009 Charles Cazabon.  Licensed under the GNU GPL version 2.
SimpleIMAPRetriever:direct@domain.com@mail.domain.com:143:
 msg    1/3983 (299328 bytes) delivered
 msg    2/3983 (2815 bytes) delivered
Continue Reading

Exim cheat sheet – Commands for troubleshoot mail issues in cPanel/DirectAdmin or any exim mail server

Below are the most common exim commands which helps an Administrator to ease his life

Print a count of the messages in the queue:

exim -bpc

Print a listing of the messages in the queue (time queued, size, message-id, sender, recipient):

exim -bp

Print a summary of messages in the queue (count, volume, oldest, newest, domain, and total

exim -bp| exiqsumm

Print what Exim is doing right now:

exiwhat

To check if the server routes the mail properly use exim -bt

# exim -bt alias@localdomain.com
user@thishost.com
    <-- alias@localdomain.com
  router = localuser, transport = local_delivery
root@localhost# exim -bt user@thishost.com
user@thishost.com
  router = localuser, transport = local_delivery
root@localhost# exim -bt user@remotehost.com
  router = lookuphost, transport = remote_smtp
  host mail.remotehost.com [1.2.3.4] MX=0

Display all of Exim’s configuration settings:

exim -bp

exiqgrep

Its used for grepping through the  exim queue.

search the queue for messages from a specific sender :

exigrep -f  user@domainname.com

Search the queue for a specific reciepient

exigrep -r user@domainname.com

To print messages older than the specified number of seconds use -o .

For example, messages older than 1 day:

exigrep -o 86400

To print messages younger than specified number of seconds use -y

Messages younger than one day can be listed  using the command

exigrep -y 86400

Print just the message-id of the entire queue:

exiqgrep -i

Managing the queue

Start a queue run:

exim -q -v

Start a queue run for just local deliveries:

exim -ql  -v

Remove a message from the queue:

exim -Mrm <message id >

Freeze a message:

exim -Mf <message id >

Thaw a message:

exim -Mt <message id>

Deliver a message, whether it’s frozen or not, whether the retry time has been reached or not:

exim -M <message id>

Deliver a message, but only if the retry time has been reached:

exim -Mc <message_id>

Force a message to  Freeze and bounce as “Canceled by Admin”

exim -Mg <message id>

Remove all frozen mails

exigrep -z -i | xargs exim -Mrm

Remove all messages older than five days (86400 * 5 = 432000 seconds):

exigrep -o 432000 -i | xargs exim -Mrm

Freeze all queued mail from a given sender

exiqgrep -i -f user@domain.com | xargs exim -Mf

View a message’s headers:

exim -Mvh <messageid>

View a message’s body:

exim -Mvb <message id>

View a message’s logs:

exim -Mvl <message id>

Continue Reading

User stats in directadmin admin area – Solved with a good client’s help :)

When one of our clients, Mr. Xavier opened an issue with us regarding the Usage stats not being shown, we were certain that this is a bug with DirectAdmin in the way how its license are read. We changed the ethernet_dev in directadmin.conf, but that didn’t work out.

Client was asking us,

In Admin Area –> Complete Usage Statistics –> Usage stats for venet0:0 is showing “None”

It’s possible to fix this to reflect the traffic of this virtual adapter?

DirectAdmin didn’t give a direct solution. Instead provided us with a complete packed files related to DirectAdmin. So the solution was this.

cd /usr/local/directadmin
wget -O new.tar.gz http://files.directadmin.com/7694310/packed_es50.tar.gz
tar xvzf new.tar.gz
./directadmin p
killall -9 directadmin
./directadmin d
/etc/init.d/directadmin restart

For anyone facing this issue. I didn’t check more deeper into what changed, but must be related to htmls in data page on how device gets read.

Continue Reading


 

About this blog

This blog, acts as a knowledge repository for the world and is unofficial! Anything we find interesting in the cyber world will go here. Most cases, this blog will reflect the happiness of our staff in reaching successful solution to an issue (s)he worked on. A reference for other fellow SAGEs who come across similar issues later