# Postfix relay incoming mail[SOLVED]

## PietdeBoer

Hi guys,

I have 5 virtual mailservers, on a physical host with one external ip adress.

Each of those 5 virtual mailservers hosts handles traffic for one domain only by listening on port 25 for incoming mail.

Since i have only one external ip, i want to set up a new mailserver for relay only, this server should accept all incoming mails, filter them and relay the correct ones to the correct internal mailserver.

How could i achieve this?.. i searched some on google but i only found how to relay outgoing mail.

*Edit:

I found this:

relay_domains = $mydestination

relayhost = <postfix_relays_via_this_host.com>

But this configuration can only relay to one server, while i want to relay x.com to internal server 1, and y.com to internal server 2.

Cheers!

----------

## elgato319

Looks like transport maps can help.

```
man transport
```

 *Quote:*   

> 
> 
> main.cf
> 
> transport_maps = hash:/etc/postfix/transport
> ...

 

 *Quote:*   

> 
> 
> /etc/postfix/transport
> 
> domain1.com    smtp:[10.0.0.1]
> ...

 

----------

## cach0rr0

yeah, transport maps will do this without issue

I do this when sending to the major plays, who don't like my dynamic IP  :Smile: 

```

gmail.com       smtp:smtp.comcast.net

.gmail.com      smtp:smtp.comcast.net

googlemail.com  smtp:smtp.comcast.net

.googlemail.com smtp:smtp.comcast.net

aol.com         smtp:smtp.comcast.net

.aol.com        smtp:smtp.comcast.net

hotmail.com     smtp:smtp.comcast.net

.hotmail.com    smtp:smtp.comcast.net

yahoo.com       smtp:smtp.comcast.net

.yahoo.com      smtp:smtp.comcast.net

```

The rest I deliver directly - until of course I hit another rejection, at which point I'll add them to the list too!

Just remember you do need to postmap it. 

just make sure $mydestination isn't set to any of the domains you wish to relay. That's what I'd watch out for really, otherwise if $mydestination is set to one of the domains you were hoping to relay, I *think* it'd take precedence, and en up delivering accepted mail locally.

----------

## PietdeBoer

Thx, going to try this out!

----------

## PietdeBoer

Thx guys, it worked!

For the ones reading this thread in the future, i added these lines to a fresh postfix install:

relay_domains = example.com example2.com

transport_maps = /etc/postfix/transport

Then i created a textfile /etc/postfix/transport, added these lines:

example.com       smtp:192.168.1.200

.example.com      smtp:192.168.1.200

Then i converted the textfile to a readable format for postfix by "postmap /etc/postfix/transport"

Reloaded my postfix configuration and it worked like a charm!

----------

