I have a Postfix SMTP server running at home which can't send or receive mails because of an ISP restriction. (no incoming port 25, nor outgoing)
I have a VPS with a public IP that I want to use to relay my home mails to the internet.

It should go like this:
receiving mail: Internet > VPS Relay > Homeserver
sending mail: Homeserver > VPS Relay > Internet

I managed to succesfully setup an outgoing postfix SMTP relay which works. The problem now is receiving mails: if I tell the relay to send incoming mails to my home server it works, but it also sends all outgoing mail back to my home server (which sends it back to the relay which sends it back to my home, ...)

I tried to use a SSH tunnel to forward incoming mails on my VPS to my home server, which worked, but also made it an open relay. (The requests came from localhost so everything was allowed)

The only thing I need to know is how to tell postfix to send incoming mails to my home server and outgoing to the internet, but I couldn't manage to find it.

Thanks for taking a look!

Home server relevant config: postconf -n

myhostname = [*homeservers public dns name*] mynetworks =, [*my public relay's IP*]/32 mynetworks_style = subnet myorigin = $myhostname relay_domains = $mydestination relayhost = [*my public relay's domain name*]:587

VPS server relevant config: postconf -n mydestination = localhost myhostname = [*VPS public dns name*] mynetworks =, [*home server public ip*]/32 mynetworks_style = subnet relay_domains = soft_bounce = yes transport_maps = hash:/etc/postfix/transport


The issue is that you have not set "mydestination" so it's defaulting to the value of my hostname, rather then the domain name(s) you are trying to receive mail for, and rejecting other email as not local.

  • Should I set mydestination on my VPS then? My relay does relay mails, the only problem is that outgoing mails are also relayed back to the home server, which sends it back to my VPS etc.. – cyllos Nov 24 '18 at 18:09
  • No, you should set it on your home server, as this is the server that needs to locally process email. – davidgo Nov 24 '18 at 18:15
  • Thanks for helping out, but setting this doesn't make a difference. I can either receive mails but not send them, or send mails but not recieve, depending on wether my relay sends mail to my home server or not. If I enable forwarding mails to my home server everything goes there, not only incoming mails but also the outgoing. – cyllos Nov 24 '18 at 18:19
  • What does /etc/postfix/transport contain and what are the timestamps on /etc/transport and /etc/transport.db ? – davidgo Nov 24 '18 at 23:55
  • It contains * smtp:[homeserver ip]:587 – cyllos Nov 25 '18 at 10:15

I found a solution!

For those wondering: I added a second postfix server on the same host and used one for receiving and one for sending mail.

  • Well done on getting a solution - but you really don't need (or in my opinion want) 2 servers on 1 system. – davidgo Nov 25 '18 at 17:53
  • I know it is not the best solution, but right now this is good enough. If anybody knows a better solution please let me know – cyllos Nov 26 '18 at 12:20
  • Fix your transport table as above! – davidgo Nov 26 '18 at 17:25
  • Thanks for helping out. Setting this on the home server does not make any difference, as my VPS still thinks it should forward all mail to my home server, even outgoing mail. – cyllos Nov 27 '18 at 16:15
  • Can you show the timestamps of the transport and transport.db file - ie ? did you rebuild the .dB file? – davidgo Nov 27 '18 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.