In the previous section we partitioned the basic SMTP configuration of a qmail installation, to add a qmail-ofmipd service for MUA clients on the local network.
The ofmipd server may then be used to perform a variety of RFC822 header clean-ups and corrections on the messages it receives for injection into the queue. These various transformations are described in the new-inject(1), ofmipd(8), and rewriting(5) man pages installed with the mess822 package.
Two mechanisms are provided to configure the header transformations made by ofmipd:
Both of these components are optional. The rewrite control file is used to specify transformations to the hostname part of user@hostname addresses, and is discussed on its own page.
The cdb datafile is used to rewrite return-path addresses, and is discussed now.
Remember way back when we set up the fastforward installation, we gave all of our users some nice full names to use for their email. So the account "clove" was provided with the alias "courtney.love", and "jimm" was given the alias "jim.morrison".
All the users had to do was to configure their MUAs --their Mutts and Thunderbirds-- to use the new aliases.
Unfortunately, though, some of our users are slackers. Courtney is still sending out mail addressed from "clove", and frankly it seems like Jim is dead.
Well, with our shiny new ofmipd server, we now have a way of dealing with it.
In the service directory for qmail-ofmipd, use your text editor to create a plain-text file named from.dat:
# qmail-ofmipd/from.dat # ofmipname database for qmail-ofmipd service # === clove@example.org:Courtney Love:courtney.love@example.org: jimm@example.org:Jim Morrison:jim.morrison@example.org: kurtc@example.org:Kurt Cobain:kurt.cobain@example.org:
In other words, a series of instructions, one instruction per line, in the following syntax:
original is the return-path address found in the message; name and email are used to replace it.
So an original address of:
will be nicely rewritten as:
A few more things to note about the syntax of from.dat:
With regard to the first point, you will generally rely on ofmipd's use of control/rewrite to fill in missing hostnames. So if Courtney's MUA is configured with a return-path of simply "clove", the rewrite rules will be applied first, changing the address to "clove@example.org". See the section on control/rewrite for more information.
When the instructions in from.dat are complete, compile them into cdb format with the ofmipname utility:
# ofmipname from.cdb from.tmp < from.dat
Since ofmipname probably won't be among your most often used commands, here is a simple Makefile you can install to make things easier:
# qmail-ofmipd/Makefile # build/update cdb file for ofmipname # === .SUFFIXES: .SUFFIXES: .dat .cdb .dat.cdb: ofmipname $@ $*.tmp < $< chmod 644 $@ from.cdb: from.dat ofmipname $@ $*.tmp < $? chmod 644 $@ .PHONY: clean clean: rm -f *.cdb ### that's all, folks!
Now whenever you edit from.dat in the /service/qmail-ofmipd directory, just run:
# make ofmipname from.cdb from.tmp < from.dat chmod 644 from.cdb
The cdb from.cdb may now be used as the argument to ofmipd in the service run script:
The original qmail-ofmipd "run" script may now be modified to utilize the database:
#!/bin/sh # qmail-ofmipd/run # daemontools run script for qmail ofmipd service # ** ofmipd from mess822 package ** # wcm, 2003.11.20 - 2004.02.26 # === CONLIMIT=41 IP="192.168.0.254" PORT=25 CDB="./from.cdb" exec 2>&1 echo "*** Starting qmail-ofmipd..." echo "*** >> using names from: ${CDB}" exec envuidgid qmaild softlimit -m 3000000 \ tcpserver -v -hR \ -U \ -c ${CONLIMIT} \ -x /etc/tcprules/ofmip.cdb \ ${IP} ${PORT} /usr/local/bin/ofmipd ${CDB} ### that's all, folks!
Once the service is started with a cdb file, there is no need to restart it if you ever need to make any changes to the data in from.dat. Just rerun make (or the ofmipname utility as shown), and the rules in the new cdb file will take immediate effect.
Copyright © 2004, Wayne Marshall.
All rights reserved.
Last edit 2004.03.08, wcm.