A few weeks ago I have posted my guide on Setting up XDove on QNAP QTS 4.0.2. However, since then I’ve ran into a very strange problem: messages to certain domains were not delivered. What’s more, error reports were not delivered to me either! I had no idea something’s going on until I actually learned that the messages were never received. Particularly, gmx.com and qip.ru would reject the messages.

XDove contains XMail Server – open source POP3/SMTP *nix mail server. However, it has no -v flag that you’d expect of a sendmail command so you can’t see commands XMail exchanges with the remote SMTP server. The best way to debug this is to run XMail in debug mode (-Md) that will produce more output in the console. Still, the messages are far from complete:

ErrCode = -41
ErrString = Bad server response
ErrInfo = 501 Syntax error in parameters or arguments
SMAIL SMTP-Send MX = "mx.qip.ru." SMTP = "i-forge.net" From =
"xxx@i-forge.xxx" To = "xxx@pochta.xxx" Failed !
SMTP-Error = "501 Syntax error in parameters or arguments"
SMTP-Server = "mx.qip.ru."

We now know there’s a syntax error somewhere in the sequence of SMTP commands but where? XMail, as strange as it sounds (for a *nix program especially), provides us with no way of logging all commands it exchanges with remote servers (or they exchange with itself). But even if it did it looks more like a bug then misconfiguration, especially if you google for this error message.

The solution

XDove is an outdated QNAP package. It contains XMail version 1.25 while the latest version is 1.27. Two last updates fixed a number of bugs. The solution is to upgrade XDove’s XMail. But how?

You can determine your XMail version by logging into its admin panel (PHPXMail) which lists the version in the left sidebar. Typically it will say «Xmail server: 1.25».

Fortunately XMail is part of the official, maintained QPKG called «XMail» and it’s up-to-date. First you need to download the package for your QNAP architecture – from the official forum or if you don’t want to register you can use local mirrors (see below).

Once you have the ZIP file extract it. You will get one .qpkg file. This is actually a TAR+GZIP archive but with some shell commands in front. To extract it first edit it with the hex editor removing everything before and including shexit 1 and the following line break (0x0A). The file will begin with bytes 1F 8B 08 00.

Save the new file giving it new extension like .tgz. Try opening it in WinRAR or 7-Zip – you should be able to see 3 files inside (qinstall.sh, qpkg.cfg and XMail_phpxmail.tgz. Extract the latter – this is the final archive we need. It contains actual XMail installation compiled for the QNAP platform you’ve chosen when downloading the QPKG file.

If you didn’t download it from the forum below are immediate XMail_phpxmail.tgz extracted using the above method:

Now we need to replacce the binaries. I assume that you already have a working XDove, which means you can send messages through SMTP/XMail and open the inbox via IMAP/Dovecot.

First off stop XDove: sh/etc/init.d/xdove.sh stop.

Go to XDove’s root – /share/HDA_DATA/.qpkg/XDove/xmail/ (/share/MD0_DATA/.qpkg/XDove/xmail/ for RAID 1). Rename bin/ to something just in case you will need the original files and then extract MailRoot/bin from the archive to this bin/. Note that it’s missing checkpassword – copy or symlink it from the old bin/. No need to place binaries into MailRoot/bin on the server because XDove is configured to expect them in XDove/xmail/bin/ instead.

Technically that’s all the upgrade but we may want to upgrade the config files too. Go to MailRoot/ on the server. The following lines have been changed in server.tab:

conf"HeloDomain"	"xmailserver.test"
"PostMaster"	"root@xmailserver.test"
"ErrorsAdmin"	"root@xmailserver.test"
#"DefaultSMTPGateways"	"192.168.1.2,192.168.1.15"
"Pop3LogPasswd"	"0"
#"SmtpGwConfig"	"NeedTLS=1,OutBind=192.168.1.1"

PostMaster is the address which will receive delivery errors when somebody sends data to your server and ErrorsAdmin is the address that will receive delivery notifications for messages sent from this server. Original sender will always receive the notification regardless of this setting (even if it’s empty or commented out).

Another changed file is smtprelay.tab which now looks like this (I’ve just replaced my old version that I haven’t edited anyway):

conf"127.0.0.1"	"255.255.255.255"

Remember to use tabs between key and value (after .1" and before "255.) here and in server.tab) or XMail won’t work properly.

This should do the trick. Start XDove and you will be done:

sh/etc/init.d/xdove.sh start

Now check XMail’s version by logging into the admin panel (PHPXMail) – it should say «Xmail server: 1.27» in the left menu.