Previous Next Table of Contents

5. Automatic Masquerading (Address Translation)

Written by Vincent Zweije <zweije@xs4all.nl>.

This method uses the generics database. This is not a trivial solution in the sense that you can quickly edit your sendmail.cf by hand. Write up a sendmail.mc and use the m4 macro language method instead. Really.

Words marked with an asterisk* can be looked up in the glossary at the end.

5.1 The Situation...

Suppose you have a dialup account at an ISP. On your own machine, you have your working account, the name of which is different from the one at your ISP. Consequently, your local and global email addresses differ.

When mail gets sent out, it would be a nice feature to automatically masquerade* your local email address to the global one as known at your ISP. Sendmail can do this by means of the generics table. You can also have multiple local email addresses, and masquerade them all to your email addres at your ISP. You can even have accounts for friends on your machine, and translate their addresses on your machine to their email address at their ISP. Ergo: the generics table is useful.

You never have to worry again about setting a Reply-To or a From in your email. And you are sure that bounces* arrive back in your ISP's mailbox instead of being lost because of a bad return address*.

5.2 Setting Up the Generics Table

The generics table is a table that maps locally valid email addresses to globally valid email addresses. The correct term for this is "masquerading". Masquerading translates email addresses, but it does not change where a message gets sent by your sendmail. (If you want to reroute messages, you need aliasing.)

A good place for the generics table is /etc/mail/generics, but you can configure any place you like in your sendmail.mc. The generics table has one line for each masquerade. The line contains two addresses separated by white space; the first address is masqueraded into the second. Here is a little example.

$cat /etc/mail/generics
lerlings  leif@lege.com
jtietze   tptietze@mail.hh.provi.de
vzweije   zweije@xs4all.nl
$

After you have changed the generics table, you must rebuild the index to it. You need the makemap program, which comes with the sendmail distribution. Go to /etc/mail, and run

#makemap -hash generics <generics
#

The index is now built.

For instance, the username I use on my home machine is "vzweije". So, on my home machine my email address is <vzweije> (there is no domain involved). When mail gets sent out, the occurrences of <vzweije> in the header* and the envelope* are masqueraded into <zweije@xs4all.nl>, which is the address of my mailbox at my ISP.

5.3 Making Sendmail Use the Generics Table

The following lines in sendmail.mc configure sendmail to actually use the generics table.

$cat /etc/mail/sendmail.mc
[...]
FEATURE(genericstable, hash /etc/mail/generics)
GENERICS_DOMAIN(love.sense.net sense.net love)
FEATURE(masquerade_envelope)
FEATURE(allmasquerade)
[...]
$

Feature "genericstable" tells sendmail to use the generics table. The extra argument, hash /etc/mail/generics, tells sendmail where the generics table is, and what type of index (hash) there is to it.

"Generics_domain" defines the domains to which you wish to apply the generics table. Normally you don't need this, because the generics table applies to local addresses by default. However, you may have a local network to which you have assigned a mail domain, which you wish to masquerade too.

Feature "masquerade_envelope" applies the rewriting process to the mail envelope* as well as to the mail header*. It means that bounces* of outgoing mail will be sent back to your ISP mailbox. If you did not have this, the bounces would be undeliverable because your local address is unknown outside your own machine.

Feature "allmasquerade" applies the rewriting process to recipient addresses as well as to sender adresses. It is useful if you send yourself a local Cc of an outgoing mail; the other recipient will see a Cc to an address he knows instead of a local address. You want this.


Previous Next Table of Contents