TMDA Pre-Configuration
MTA Configuration
You may need to make some system-wide configuration changes to your MTA software depending on which one you are running. First read the General Prerequisites section, and then read the set of instructions corresponding to your MTA:
[ qmail/Courier | Postfix | Exim | Sendmail ]
General Prerequisites
Extension Addresses
TMDA is heavily based on user "extension addresses" (e.g, username+extension@yourdomain.dom), and your MTA must be able to understand them. Some of the supported MTAs do by default, others must be configured to do so.
The character that separates the username from the extension in an extension address is often called the "recipient delimiter". The most popular choices are '''+''' and '''-''', although the hyphen is recommended. TMDA can support any recipient delimiter character though, just make sure you use the same character for your RECIPIENT_DELIMITER setting in ~/.tmda/config.
Environment Variables
TMDA receives much of its information about the envelope of an incoming message from environment variables set by the MTA. Most importantly, SENDER (the full envelope sender address), RECIPIENT (the full envelope recipient address), and EXT or EXTENSION (the recipient address extension). In order to be reliable, TMDA needs these real sender and recipient values. It can't rely on what might be in the To: or From: headers.
To use TMDA, you must make sure these variables are properly set by the time TMDA sees the message. TMDA expects these variables to be in the following format:
SENDER=sender@somedomain.dom RECIPIENT=recipient+foo@yourdomain.dom EXTENSION=foo
That is, just the e-mail address or recipient address extension, with no trailing or leading whitespace, or any other extraneous characters. As with extension addresses, some MTAs set these variables by default, others must be configured to do so.
MTA Configuration (qmail and Courier)
No changes need to be made to your configuration in order to use TMDA.
MTA Configuration (Postfix)
Enable the recipient_delimiter parameter in Postfix's main.cf if it isn't already. Make sure the character you choose matches RECIPIENT_DELIMITER in your ~/.tmda/config.
MTA Configuration (Exim)
Edit your Exim run time configuration file as follows. Note: These instructions assume Exim 4.x. According to the Exim homepage, Exim 3 and previous versions are now considered obsolete. If you are running Exim 3 and can't upgrade, you'll have to find an old version of this page.
MAIN CONFIGURATION
TMDA uses sendmail's `-f' option to set the envelope sender address on outgoing messages. By default this option is only available to Exim's "trusted users". You can also add untrusted_set_sender = * to your Exim configuration which allows untrusted users use of the -f command line option.
If you cannot set this option for some reason, a workaround is to set MAIL_TRANSPORT = "smtp" in your ~/.tmda/config, which will cause TMDA to send mail using direct SMTP instead of the sendmail command, thus bypassing this problem.
DIRECTOR/ROUTER CONFIGURATION
Exim must be configured to understand extension addresses. Add the following lines to both the userforward and the localuser directors if they are not there already:
local_part_suffix = -* # or "+*" if you prefer "user+suffix" addresses local_part_suffix_optional
Make sure the character you choose matches RECIPIENT_DELIMITER in your ~/.tmda/config.
You also might be interested in these Exim specific instructions for a server-wide TMDA setup.
TRANSPORTS CONFIGURATION
Exim only sets the SENDER and RECIPIENT environment variables by default. You must configure it to also set EXTENSION using the environment pipe option.
You must also have Exim add a Return-Path: header to the message which it doesn't do by default. Do this by enabling the return_path_add transport option.
Set return_path_add and environment as follows under the address_pipe transport:address_pipe: driver = pipe return_fail_output return_path_add environment = EXTENSION=${substr_1:$local_part_suffix}
MTA Configuration (Sendmail)
Gripes
The main difficulty with using TMDA under Sendmail, is that Sendmail does not set any of the required environment variables as the other supported MTAs do. In fact, as hard as this is to believe, Sendmail does not provide any envelope recipient information to commands run from a .forward file. In today's complex mail environments, full envelope information in user-space is essential to support advanced applications such as TMDA. It's not an accident why all the other supported MTAs do this; it's a good idea!
If you are stuck with Sendmail and find this deficiency as troubling as I do, you might consider sending a feature request to the Sendmail developers as king that the full envelope information be made available to .forward invoked programs in the form of environment variables (SENDER, RECIPIENT, and EXTENSION). This should be done regardless of whether the Sendmail installation has procmail configured as its local mailer or not.
Sendmail's default recipient delimiter is a plus (+) character, but unlike the other supported MTAs, Sendmail doesn't allow the administrator to change this default. You are stick with + even though this presents problems that other recipient delimiters such as '''-''' do not have. If you find this inflexibility troubling, consider sending a feature request to the Sendmail developers asking that the recipient delimiter be made configurable.
Configuration
In order to use TMDA, you need some way to obtain the necessary envelope information and set the required environm ent variables. It matters not how you do this, just as long as these variables are properly set by the time TMDA sees the message. We provide example solutions below for sites with procmail or maildrop configured as the local mailer.
Procmail
If your Sendmail installation is using procmail as its local mailer, the necessary envelope information is passed as a command line argument to procmail, typically introduced by the "-a" flag. Your .procmailrc will then be able to construct the environment variables from this argument. The necessary Sendmail configuration changes are covered below, and a sample .procmail rc is given on the ServerConfiguration page.
Make sure procmail is installed on your server, and then add the following rule to your sendmail.mc file if it is not already present (most Linux distributions already define this!):
FEATURE(`local_procmail', `/usr/bin/procmail')
Now run sendmail.mc through m4 to produce your new sendmail.cf file, and restart Sendmail so the changes will take effect.
Maildrop
If your Sendmail installation is using maildrop as its local mailer, the necessary envelope information is passed as command line arguments to maildrop. Your .mailfilter will then be able to construct the environment variables from these arguments. The necessary Sendmail configuration changes are covered below, and a sample .mailfilter is given on the ServerConfiguration page.
Make sure maildrop is installed on your server, and then add the following rule to your sendmail.mc file if it is not already present:
FEATURE(local_procmail,`/usr/bin/maildrop',`maildrop -d $u $h $j $g')
Now run sendmail.mc through m4 to produce your new sendmail.cf file, and restart Sendmail so the changes will take effect.
- If for some reason any of your $ macros are not set properly please consult the Sendmail documentation. The example above was taken from a Redhat Linux 9 system.