0% found this document useful (0 votes)
142 views2 pages

How To Rewrite Outgoing Address in Postfix

The document provides instructions for configuring Postfix on a Linux machine to rewrite the outgoing email address to a custom domain. It describes editing the main.cf file to set the mydomain variable and enable all network interfaces. A generic map file is then specified and edited to map the original addresses like [email protected] to the desired addresses like [email protected]. Finally, the generic map is compiled into a database for Postfix to use when rewriting outgoing addresses.

Uploaded by

Saka Kely
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views2 pages

How To Rewrite Outgoing Address in Postfix

The document provides instructions for configuring Postfix on a Linux machine to rewrite the outgoing email address to a custom domain. It describes editing the main.cf file to set the mydomain variable and enable all network interfaces. A generic map file is then specified and edited to map the original addresses like [email protected] to the desired addresses like [email protected]. Finally, the generic map is compiled into a database for Postfix to use when rewriting outgoing addresses.

Uploaded by

Saka Kely
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

How to rewrite outgoing address in Postfix

Sometimes I find myself configuring an internal Linux machine to be able to send emails for
alerts or from a particular application. Since this will not be a primary mail server, I just want
to rewrite the outgoing address to be something that make sense with the proper domain for
the users. Here are the quick steps to accomplish this:

vi /etc/postfix/main.cf

Modify the "mydomain" variable to your email domain

mydomain = example.com

Make sure to uncomment the proper network interface. I'm usually lazy and just do all.

inet_interfaces = all

Now at the bottom of this file you need to specify the generic map file for rewriting the
address.

smtp_generic_maps = hash:/etc/postfix/generic

Save and exit main.cf. Now we need to edit /etc/postfix/generic

vi /etc/postfix/generic

You need to specify the mapping of the original address to the one you want. Since in this
case I just want to rewrite everything I usually add the following two lines and it seems to
catch everything.

[email protected] [email protected]
@example.com [email protected]

Save and exit the file. Now we need to create the postfix db.

postmap /etc/postfix/generic

This will create the /etc/postfix/generic.db hash file.


Generic mapping for outgoing SMTP mail

Some hosts have no valid Internet domain name, and instead use a name such as
localdomain.local. This can be a problem when you want to send mail over the Internet,
because many mail servers reject mail addresses with invalid domain names.

With the smtp_generic_maps parameter you can specify generic(5) lookup tables that replace
local mail addresses by valid Internet addresses when mail leaves the machine via SMTP. The
generic(5) mapping replaces envelope and header addresses, and is non-recursive. It does not
happen when you send mail between addresses on the local machine.

This feature is available in Postfix version 2.2 and later.

Example:

/etc/postfix/main.cf:
smtp_generic_maps = hash:/etc/postfix/generic

/etc/postfix/generic:
[email protected] [email protected]
[email protected] [email protected]
@localdomain.local [email protected]

When mail is sent to a remote host via SMTP, this replaces [email protected] by his ISP
mail address, replaces [email protected] by her ISP mail address, and replaces other
local addresses by his ISP account, with an address extension of +local (this example assumes
that the ISP supports "+" style address extensions).

You might also like