Johan's qmtpc qmail-remote patch

Peter wrote a patch to let qmail-qmtpd check control/badmailfrom. See below!

What is QMTP

QMTP is a replacement for SMTP suggested by DJB, the author of qmail. More info is available here. You will also want to read about MXPS here.


"Why?" you may ask. "What is the purpose of this patch?"

There may be situations where you want to use QMTP between two hosts, without announcing the QMTP capability to the whole (educated) world by, eg, MXPS. That's when you need to specify explicit QMTP routes - which this patch permits.

It also fixes some other stuff, listed below.


If you want to get some of the more common qmail- and DJB-related mailing lists by QMTP, you will want to check out Peter's sublist page.

Russell Nelson has a qmtpd tarball here. You'll need that for incoming QMTP.


This patch tries to be as gentle as possible about the logging, so that log analysis tools still work. However, you'll have to check that it really does...

It may also break other stuff. It hasn't for me, nor anyone else.

It doesn't patch your man pages or other documentation (yet). This is all the documentation there is.


This patch is based on this patch by .

had some good ideas and fixed qmail-qmtpd (see below). He also fixed the documentation for my patch!

Ian Lance Taylor found out what the strange behaviour I noticed was caused by, and fixed it. Cool! And yes, he's the Ian Taylor...

There is an older patch (1998-08-03) by Stefan Paletta that will speak QMTP if the port number in smtproutes is 209.

Naturally, I also have to thank DJB for qmail, djbdns etc.

The patch

and I saw that qmtpd doesn't do control/badmailfrom checking, so Peter wrote a patch to qmail-qmtpd. He also did his homework and updated all related man pages...

Wedneday version, 1.5 (2001-01-17) now includes Ian Lance Taylor's patch that allows for SMTP if the QMTP connection fails. It also changes the logging a bit - the failed QMTP connection will not be logged as DJB's logging architecture makes it hard to log anything before knowing wheter the total transaction was successful. This patch will try SMTP to port 25 if QMTP fails, regardless of whether the decision for QMTP was based on MXPS or control/mailroutes. There is also a gzip'd archive.

Thursday version, 1.4 (2001-01-11) now has documentation (by Peter van Dijk) and what Peter and I consider the best logging style. It also fixes a minor glitch about the new feature of 1.3 :-)

Tuesday pm version, 1.3 (2001-01-09[2]) now says "unable to establish a QMTP connection" if that's what happened.

Tuesday version, 1.2 (2001-01-09) that makes logging from smtp and qmtp more alike and reads mailroutes if that exists, and smtproutes if mailroutes doesn't exist.

Sunday version, 1.1 (2001-01-07) that fixes a few issues about memory allocation, nothing very serious though.

Old version, 1.0 - the (2001-01-06) original.

Changes / TODO

Further suggestions are very welcome!


  • Nothing right now, really. But gzip'ed qmtp sounds cool...


  • Ian Lance Taylor's patch included, and minor logging changes made.
  • Peter fixed all documentation for this patch: man pages and qmail-showctl. Thanks a bunch!
  • Took a look at relaying and badmailfrom in qmail-qmtpd. Peter fixed what I discovered. Thanks!
  • Fourth release, also 2001-01-10: now says "unable to establish a QMTP connection" if that's what happened.
  • Third release, 2001-01-10: Made QMTP logging more like SMTP logging, reads mailroutes first and smtproutes if no mailroutes.
  • Second release/fix, 2001-01-08: added checking for failure to allocate memory in string copy (data from contol file, not from network).
  • First release, 2001-01-06: added checking of control/mailroutes instead of control/smtproutes, with ability to specify protocol in this file.

Documentation, sortof

To use qmtp for incoming mail, you'll want to start the qmail-qmtpd service on your mail server and modify your MX records in accordance with MXPS

Peter's documentation

				What I changed:
				- added mailroutes to man qmail-control (in the long list and in the
				  'comments are allowed in' part
				- added QMTP in lots of places in man qmail-remote that said 'SMTP'
				- added mailroutes (copied from smtproutes and edited :)
				- added note to smtproutes about ignoring it when mailroutes exists
				- qmail-showctl lists mailroutes' content if mailroutes exists, and is
				  able to print
				smtproutes: mailroutes exists, ignoring smtproutes
				  if needed :)    

My documentation

				This is the fourth release of this patch, dated 2001-01-11.
				It will now log smtp and qmtp transactions with similar syntax,
				attemting not to break log parsers. It will also use smtproutes
				if mailroutes doesn't exist.

				This patch is based on Russell Nelsons'  patch
				(qmail-1.03-qmtpc.patch) which he released 2001-01-05.
				It is available from

				This patch introduces a file named control/mailroutes which
				replaces control/smtproutes from the original qmail. The format
				is the same, exept for a last field, specifying the protocol.
				You may sipmly copy the smtproutes file to mailroutes.

				Two example lines looks like this:

				In the first case, QMTP will be used to transfer messages for
				the domain to, port 209.

				In the second case, SMTP will be used to transfer messages for
				the domain to, port 25.

				PLEASE NOTE that SMTP will be assumed as protocol even if you
				specify 209 as the port, but no protocol. In fact, SMTP will be
				used in all cases except if the last field is exactly 'qmtp'.

				PLEASE NOTE that you cannot specify only a protocol. If you wish
				to specify a protocol, you MUST specify a port. Bad things may

				control/smtproutes will be read if, and only if, control/mailroutes
				doesn't exist.

				YMMV and UAYOR.

				To report success:

				% (echo 'First M. Last';echo 'qmail-remote-qmtp-mailroutes';uname -a)|mail
				Replace First M. Last with your name.

				No warranties whatsoever.
				Written by Johan Almqvist,