I managed to get a little email archiving system working which I am finding to be potentially quite useful in the future. The beauty of it is that every email going in and out the system is saved onto a google gmail account, which harnesses their power of filtering, searching and labelling!
This setup was specifically aimed at a PLESK-run box but I’m sure it would work on any box with a qmail/qmail-scanner enabled mailserver, actually any MTA with a Maildir format.
Firstly, you must install qmail-scanner onto your plesk system. This is quite straightforward and I have a tutorial here to help you install qmail-scanner onto a plesk server.
Once you’ve done that, go to /etc/qmail-scanner.ini and edit the line that says
ARCHIVE=”no”
to
ARCHIVE=”yes”
and then reconfigure qmail-scanner by running
qmail-scanner-reconfigure
Now you’ll start receiving archived email into folder path /var/spool/qscan/archives/new/
The trick to move these to gmail is set up a cronjob to move these archives to an email account you create on your server via PLESK/qmail and then tell gmail to retreive it via pop.
So, firstly you must create an email account. Doesn’t matter what it’s called, where it is or anythinng else, just create an email account as you would on a PLESK domain of your choice with mailbox enabled and a decent password.
Once you do this, create a script somewhere in your system with these contents (I chose /var/qmail/ for this example)
#!/bin/sh
mv /var/spool/qscan/archives/new/* /var/qmail/mailnames/<yourdomain>/<mailname>/Maildir/new/ > /dev/null 2>&1
chown -R popuser:popuser /var/qmail/mailnames/<yourdomain>/<mailname>/Maildir/new/
Next create a cronjob on your server (Server > Scheduled Tasks) and run that. I run it under root so that it doesn’t mess up on setting permissions. Depending on how much mail you get you need to run this quite regularly, otherwise mv just won’t work! In my case, once a day wasn’t enough so I just set it to every 5 minutes… probably less intensive to do in increments anyway.
So now you could download these to any pop or imap account, but we choose gmail because of the storage space, reliability, and speed at sifting through huge archives of mail. You probably want a new gmail account for this I imagine, and in many cases you may want to splurge on a paid plan for more space, depending on how much email you get. I’ll leave that to you.
In your desired gmail account go to Settings > Accounts and you’ll see an option (2nd one down at time of writing) called “Get mail from other accounts:“. Click on the link to add a new account.
The first windows asks for the email account you just set up on PLESK. The second window will look like the following. Change the values in the textbox to match your server and email account.
That’s it! Sit back and watch the emails roll in, and make the best of gmail’s power! You can create a filter for every email account you have on the server and apply a label automatically, so if you ever need to access a lost email (or snoop on your employees) you won’t have to wait for ages as your poor email client tries to go through thousands of emails to get what you want.