No, this isn’t about how to run a mail server when you’re a bit inebriated. For those who don’t know, Wine is a Windows ’emulator’ for Linux (actually Wine Is Not an Emulator, but by calling it an emulator it makes it a bit easier for people to understand). The main ‘problem’ with Wine, is that it is not a complete implementation of the Windows APIs, so some functions won’t work.
This is an advanced article, and requires a fair amount of technical competence, and experience of Linux as well as VPOP3.
There are several free POP3/IMAP4/SMTP servers available for Linux, but we do regularly get enquiries about whether we do a Linux version of our VPOP3 software. This is mainly because VPOP3 is a lot easier for less technical people to configure and manage than the freely available alternatives. Up to now, we’ve said “there’s no Linux version, and we don’t have plans to make one, but you may be able to get it to work under Wine – good luck”. Now, for various reasons, we decided we’d like to give it a try. The main advantage of running VPOP3 on Wine is that you don’t need to buy a Windows licence (you still need a VPOP3 licence).
Well – the good news is – I got it to work. The bad news is, it wasn’t trivial. So, this article will take you through what I did to get it to work.
Note: Running VPOP3 under WINE is NOT officially supported, so you may encounter problems. We’re happy to hear of any problems you may encounter, but cannot guarantee to fix them. This is currently experimental!
The steps I took were:
- Install Ubuntu Desktop
- Update WINE to v1.6
- Install PostgreSQL on Ubuntu
- Install VPOP3
- Manually configure VPOP3 to take account of the missing features in WINE and Linux security
- Run VPOP3, test and configure
Install Ubuntu Desktop
VPOP3 does not really need any desktop features, but VPOP3 does have hidden windows, so WINE needs to have an X11 driver installed. For testing, the simplest way to achieve this was to install Ubuntu Desktop. Theoretically I could have installed Ubuntu Server, and then added an X11 driver, but my Linux knowledge is not that advanced yet.
I installed Ubuntu Desktop 12.04 32 bit from here. It should work with the 64 bit version of Ubuntu, but this wasn’t tested. I used 12.04 because that is the current LTS version of Ubuntu, so it is what many people use for server type applications.
Update WINE to v1.6
The next step was to install WINE v1.6. I originally tried with the version of WINE that comes packaged with Ubuntu 12.04 – WINE v1.4, but that failed miserably…
I used the instructions here to get the v1.6 package of WINE for Ubuntu. I used the command prompt, so I opened a terminal window, and typed
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.6
This installed WINE v1.6 on the Ubuntu PC. The latest development version of WINE is 1.7, but I went with the stable 1.6 version to see if that would work first.
Install PostgreSQL on Ubuntu
The VPOP3 installer includes an installation of PostgreSQL, but PostgreSQL works fine on Linux itself, and it seemed daft to run the Windows version via WINE, when the native Linux version will work better and just take a minute or two to set up
In a terminal window, type: sudo apt-get install postgresql
To get into the postgresql console, I then typed ‘sudo passwd postgres‘ and entered a new password for the ‘postgres’ user. Then, I typed su – postgres and entered the password to log in as that user. Then, I typed psql to access the postgresql console. Then, to set up the PostgreSQL user & database for VPOP3, I typed:
create user vpop3 login password ‘vpop3pass’;
create database vpop3 owner vpop3 encoding ‘SQL_ASCII’ template template0;
Type exit to logout from the ‘postgres’ user.
Now, I need to install VPOP3. As I like a command prompt, I downloaded the current version (v6.6) by typing
(You may want to download a later version if one is available)
Alternatively, you could use a standard web browser to download the VPOP3 installer
To install the software, just type: wine vpop3_v66_2678.exe
You should see the familiar setup program, so go through the settings as normal, except make sure you uncheck the postgresql component when choosing components. Also, note that I unchecked the VPOP3 Antivirus option as I wanted to keep things simple for the test. That may work (I see no reason why it shouldn’t), but it was not tested here.
You should be asked for ‘Database Information’ since you are not using the standard PostgreSQL installation. Here, type 127.0.0.1 in the Host Name box, and leave the other settings as their defaults (as below).
Note that during the installation, you may see lots of text in the command prompt. Usually this is hidden, so just ignore it.
At the end of the installation, uncheck the Start VPOP3 box – if you don’t, then it’s not a disaster, but VPOP3 will stop shortly after starting up
Manually configure VPOP3
WINE is not a complete implementation of the Windows API, so some features were missing, such as automatic detection of IP addresses. Also, in Linux there is a biggish problem which is that only the root user is allowed to bind to IP ports 1-1023. This means that when VPOP3 tries to bind to ports 25 (SMTP), 110 (POP3) etc, it is blocked from doing so. This will make VPOP3 fail to start.
To fix these problems we need to change some settings in the database.
At the command prompt, go to the .wine/drive_c/vpop3 folder. In WINE this is the same as the C:\VPOP3 folder in the ‘virtual Windows’ installation.
In that folder should be a file called DBCHANGES.DAT. If you accidentally started VPOP3, then file will have been renamed to DBCHANGES.1, so rename it back.
Now, edit that file – I prefer NANO, so I run nano dbchanges.dat
Near the bottom of this file will be lines saying things like:
INSERT INTO settings.settings (name,updateuser,value) VALUES(‘POP3ALLOWED.DAT’, ‘Installer’, ‘0\n1|0||1|0|’);
You need to edit all those lines, to remove the ‘1|0||1|0|’ from the setting value, so they say something like:
INSERT INTO settings.settings (name,updateuser,value) VALUES(‘POP3ALLOWED.DAT’, ‘Installer’, ‘0\n’);
This tells VPOP3 to allow connections from anywhere, rather than just from the local network. This is because VPOP3 cannot automatically detect the local network addresses when running in WINE. We MUST change this to a more appropriate setting once we can get into the settings.
Also, add a couple of lines saying
DELETE FROM settings.settings WHERE LOWER(name)=’mailhttpallowed2.dat’;
INSERT INTO settings.settings (name,updateuser,value) VALUES(‘MAILHTTPALLOWED2.DAT’, ‘Installer’, ‘0\n’);
This allows administrator access from anywhere which has Webmail access.
Then, at the bottom of the file, add the lines
DELETE FROM settings.settings WHERE LOWER(name)=’\\service-0\\~bindings’;
DELETE FROM settings.settings WHERE LOWER(name)=’\\service-1\\~bindings’;
DELETE FROM settings.settings WHERE LOWER(name)=’\\service-5\\~bindings’;
DELETE FROM settings.settings WHERE LOWER(name)=’\\service-9\\~bindings’;
DELETE FROM settings.settings WHERE LOWER(name)=’\\service-10\\~bindings’;
INSERT INTO settings.settings (name,value) VALUES(‘\\Service-0\\~Bindings’, ‘|8110’);
INSERT INTO settings.settings (name,value) VALUES(‘\\Service-1\\~Bindings’, ‘|8025’);
INSERT INTO settings.settings (name,value) VALUES(‘\\Service-5\\~Bindings’, ‘|8389’);
INSERT INTO settings.settings (name,value) VALUES(‘\\Service-9\\~Bindings’, ‘|8143’);
INSERT INTO settings.settings (name,value) VALUES(‘\\Service-10\\~Bindings’, ‘|8119’);
These settings changes tell VPOP3 to bind to ports 8000 above their normal ports, so SMTP is on port 8025 instead of port 25. This is a bit annoying, but we should be able to tell Linux to redirect them back later.
An alternative to doing this would be to run WINE as the root user, but everyone says that is a bad idea, so we won’t do that here.
Run VPOP3, test and configure
You can now start VPOP3 as a service, by running wine net start vpop3, and stop it by running wine net stop vpop3
If you want to run VPOP3 as an application instead (which can be more useful for problem solving), you can run wine c:/vpop3/vpop3, and to stop it run wine c:/vpop3/closevpop3
In some cases WINE can refuse to clean up resources after use, so stopping the WINE server totally can clean this up – run /usr/bin/wineserver -k
Once VPOP3 is running, you should be able to access the VPOP3 settings as usual (http://<ip address>:5108). During the configuration, we strongly recommend going to the various Services in the VPOP3 settings, and going to the IP Access Restrictions tab, and setting up restrictions as appropriate. This is especially important for the SMTP service – failure to do so could make your VPOP3 server into an open relay.
When you are running VPOP3 in WINE, you may see text appear on the console beginning with fixme: – these are generally Windows API function calls which VPOP3 is using, but which WINE does not implement fully. In our testing we haven’t encountered any of these which cause VPOP3 a problem, but just remember that these aren’t issues with VPOP3…
Remember that is is not officially supported, and we just put it here for you to play with. We don’t recommend using it like this in a critical production environment. However, as VPOP3 stores all its data in PostgreSQL, which we are running as a native Linux program, that should be as safe as it would be on Windows, so even if VPOP3 under WINE crashes, you shouldn’t lose data. At the worst you would be able to run VPOP3 on a Windows PC, and have it connect to the Linux installation of PostgreSQL to see the data.
VPOP3, as set up above, will provide POP3, SMTP and IMAP4 (in VPOP3 Enterprise) services on ports 8110, 8025, and 8143 respectively. While it is certainly possible to use it like this, it can be a bit annoying since you will need to reconfigure each email client to use these non-standard ports. Also, incoming SMTP won’t work unless port 25 is redirected to reach VPOP3 on port 8025.
It should be possible to use IPTABLES to redirect the ports to VPOP3, however this isn’t something we’ve done yet – user comments are welcome, otherwise we will come back to revisit this later.