Sendmail forwards to ListManager
Note that this documentation is current for Sendmail versions up to 8.12.9. For further inquiries about Sendmail beyond the scope of this documentation, please see http://www.sendmail.org/.
Create an alias and tell Sendmail to forward email addressed to the alias to ListManager that runs on another port.
The main advantage of this approach is that it will work with virtually with any system configuration. Both Sendmail and ListManager can coexist on the same machine, without having to assign new TCP/IP addresses or any other significant system changes.
Add DNS Entry
The first step in using this approach is to define an alias (an alternate name) for your machine.
Please note: You cannot use a DNS CNAME for this purpose, because newer versions of Sendmail will often detect the CNAME in the RCPT TO: address and rewrite it to be the host the CNAME points to (canonical form). Thus, negating the purpose of creating the CNAME in the first place.
Instead, you should add a new 'A' record in your DNS with the "alias" name, pointing to the same TCP/IP address already used by your machine. There will then be two 'A' records for your TCP/IP address, defining the two names.
For example, to define an alias called "lists" for a machine named "apollo" you would first locate the line which reads "apollo IN A 207.105.6.2", copy and duplicate that line, defining the alias name in the second line. Your DNS file would read:
apollo IN A 207.105.6.2 ; the original host name
lists IN A 207.105.6.2 ; the new "alias" host name
Please consult your network administrator if you need help in doing this.
Add Entry to "hosts" file
If you haven't done so already, you must add an entry to the "hosts" file on your machine. Typically, the file will be found in /etc, and a host entry will look something like:
207.105.6.2 lists.example.com lists
This is only an example. Depending on which flavor of Unix or Linux you are running, there may be slight variations in the syntax of defining a host. The file may not be in /etc.
Once the machine has been configured to listen for the new hostname, you will need to stop and restart your network services for this to take effect.
Once your alias is configured, go ahead and install ListManager.
Move ListManager to Port 26
You now need to tell ListManager to listen for incoming SMTP connections on an alternate port. Because Sendmail will be listening to port 25 (the SMTP standard) you should pick something which does not conflict. A common choice is port 26.
While you are installing ListManager, you will be given the option to do this through the installation program. Alternatively, you can inform ListManager that it should use the alternate port with the "smtpport" command line parameter. For example:
lm smtpport 26
ListManager will respond with "Successfully updated SMTP port number"
Configure Sendmail
Finally, you need to define a Sendmail rule, to tell Sendmail, to forward mail which is addressed to the alias (the new "DNS A record" you just created) to ListManager that is running on the alternate port. The method described below was tested on RedHat Linux 6.1with Sendmail 8.9.3.
There are four steps involved: 1) define a mail delivery agent, 2) define a RULE 0 to look for your alias and use that delivery agent, 3) "allow" Sendmail to relay to the host, and 4) add an entry to your mailertable.
Define a delivery agent: Edit /etc/mail/sendmail.cf (or wherever it may be on your system) and search for a line which begins with "M". This marks the beginning of your mail agent definitions. When you find that, add the following entry to that section:
Mlyris, P=[IPC], F=mDFMuX8ak, E=\r\n, L=990,
T=DNS/RFC822/SMTP,
A=IPC
$h 26
It is very important that you properly use tabs when adding this agent definition. There are tabs before each of the equates "P=", "T=", and "A="
This command defines the "ListManager" mail agent with the following settings:
P=[IPC] - Send this message using the network.
F=mDFMuX8ak - Tell sendmail how the delivery agent will behave. In turn, these are: m - "multiple
recipients possible"; D - "Need Date: in header"; F - "Need From: in header";
M - "Need Message-ID: in header"; u - "Preserve uppercase for username"; X - "Delivery
agent needs RFC821 hidden dot"; 8 - "Suppress EightBitMode=m MIME encoding"; a - "Run
extended SMTP protocol"; k - "Don't check for loops in HELO command".
E=\r\n - Use linefeed and carriage-return as end of line characters.
L=990 - Set 990 as the maximum number of lines in a message.
T=DNS/RFC822/SMTP - Used for DSN (Delivery Status Notification).
A=IPC $h 26 - Arguments to give to mail agent (for IPC delivery, the arguments indicate the hostname
and port to pass the message to).
Create S0 rule: The next step is to add the rule that will direct ListManager-bound mail to the mail agent defined above. In the sendmail.cf file, search for a line that reads “S0” and add this line below the "S0":
R$*<$*@lists.example.com$*>$* $#lyris $@lists.example.com $:$1<$2@lists.example.com$3>$4
In the above line, change the word "lists.example.com" in each of the 3 instances to your full hostname alias. The line above assumes that your domain name is "example.com" and that your ListManager hostname alias is "lists"
Here is a detailed analysis of the line:
[1] Searches for "lists.xyz.com" in the RCPT TO: address: R$*<$*@lists.example.com>$*.
[2] Must be a tab (important: sendmail will start with an error if you forget the tab).
[3] Specifies the ListManager delivery agent: $#lyris.
[4] Specifies the hostname: $@lists.example.com .
[5] Specifies the complete username to deliver to:$:$1<$2@lists.example.com$3>$4.
This line is not as complicated as it looks: all we have done is instructed Sendmail to look for "@lists.example.com". In the RCPT TO: address, and forward messages that match this on to the "ListManager" mail agent.
Very important: The character before $#lyris must be a tab, all the other blanks must be a space, and must not be a tab. The rule will not work correctly unless this is exactly right. Sendmail will give an error when you try to start it.
Be sure that you have changed the text "lists.example.com" in all 3 places in the rule above, to be your ListManager host name.
"Allow" sendmail to relay to the alias: The next step is to configure Sendmail to allow relaying to the alias you are using for ListManager. To accomplish this, you will need to add the hostname to /etc/mail/relay-domains. If that file does not exist, you need to create it and add the alias to it. The format required is one hostname per line.
Please note that using "Cw" or "Fw" to define aliases for the localhost does not accomplish the same end. These commands are often used to inform sendmail that it should accept mail for those hostnames, not relay it.
Add entry to mailertable: The final step is to add an entry to the mailertable. Edit the /etc/mail/mailertable file by adding an entry like the following:
lists.example.com lyris:[127.0.0.1]
You would replace the "lists.example.com" with the alias of your ListManager. The alias is separated from the mailer entry by a tab.
Once the mailertable entry is complete, the final step is to run the "makemap" program. You should be in the /etc/mail directory when you run this command:
/usr/sbin/makemap hash mailertable < mailertable
Now, restart Sendmail. The easiest way to do this is to first "kill" Sendmail, then restart it with "/usr/lib/sendmail -bd"
To test that these changes work, start ListManager in the foreground with the "debug" parameter, like this: "lm start debug". Then send email to the alias name, such as "lyris@lists.example.com". You should see immediate activity on the ListManager screen, indicating that the email message was received.
You should also receive a prompt reply to your email message from ListManager.