How to forward certain addresses only to another mail server with Postfix

postfix

For automatically handling bounce mail in an application, I need bounces sent back to certain adresses only to be delivered by pipe to the program which will manage these. There is two options :

  • Forward those addresses to another SMTP server, which will pipe every received mail
  • Pipe only these addresses on the main mail server

Is there any efficient and simple way to do one of those with Postfix?

Thanks.

Best Answer

# vi /etc/postfix/main.cf

virtual_alias_domains = yeswedeal.com # virtual_alias_domains = example.com virtual_alias_maps = hash:/etc/postfix/virtual

# vi /etc/postfix/virtual

rajat@yeswedeal.com rajat@ossc.com

You can also implement a catch-all address i.e. email sent to tom@example.com and jerry@example.com should be forwarded to somewhereelse@another.domain.com

@example.com somewhereelse@another.domain.com

Save and close the file. Type the following command to restart postfix:

# postmap /etc/postfix/virtual # service postfix reload