postfix: forward all mail sent to subdomain to other server

by speendo   Last Updated January 13, 2018 20:00 PM

I have a postfix mail server running on a Debian machine.

This server handles all incoming mail. However, I want all mail sent to a certain subdomain to be handled by another mail server running on another port on the computer.

In other words, all mail going to *@subdomain.domain.tld should go to address and port XX.XX.XX.XX:YYYY

At the moment I handle aliases in /etc/postfix/virtual but I don't see how to enter this rule there.

I should also mention, that postfix is (probably) not equipped to receive any mail coming to the subdomain at the moment. Therefore it would be great if you could explain how to get there from the start...

How can this be achieved?



Answers 1


If I understand your question correctly, you have to (1) enable relay for this domain and (2) set the destination server in transport map.

Backup the postfix config file before any changes (not required, but recommended).

  1. In order to allow relay, you need to set relay_domains = subdomain.domain.tld in your postfix config (most likely /etc/postfix/main.cf).

  2. Then, you need to set destination server in the config file for this domain using transport_maps = hash:/etc/postfix/transport (or any other file postfix has access to); create this file with content subdomain.domain.tld smtp:XX.XX.XX.XX:YYYY, (assign permissions if needed) and build the database using shell command postmap /etc/postfix/transport.

Don't forget to restart postfix after your changes.

Kotoniu
Kotoniu
January 13, 2018 19:29 PM

Related Questions


Postfix sent mails are bounced or go to spam

Updated January 04, 2016 14:00 PM

postfix causing server to hang after 1-2 days of use

Updated January 12, 2018 23:00 PM


Postfix does not send mails to external aliases

Updated January 01, 2017 08:00 AM

Postfix on linux not sending mail

Updated September 27, 2017 11:00 AM