Documente Academic
Documente Profesional
Documente Cultură
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
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
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.
root@example.com no-reply@example.com
@example.com no-reply@example.com
Save and exit the file. Now we need to create the postfix db.
postmap /etc/postfix/generic
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.
Example:
/etc/postfix/main.cf:
smtp_generic_maps = hash:/etc/postfix/generic
/etc/postfix/generic:
his@localdomain.local hisaccount@hisisp.example
her@localdomain.local heraccount@herisp.example
@localdomain.local hisaccount+local@hisisp.example
When mail is sent to a remote host via SMTP, this replaces his@localdomain.local by his ISP
mail address, replaces her@localdomain.local 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).