Postfix version: 2.10.1

We have applications that send mail as app@domain.com. These applications send to a postfix mail server, to relay mails. I would like to rewrite the from address to be app@newdomain.com. I realise we need to change it on the app, but these changes will only go live in a few months, so I am trying to rewrite in postfix in the intrim

I have been able to rewrite all mails to app@newdomain.com but i just want mails from app@domain.com to be rewritten.

vi /etc/postfix/sender_canonical adding the following

/.+/    app@newdomain.com

This works, but changes all mail sent from the Postfix server to app@newdomain.com

I have also tried adding

 /app@domain.com/ app@newdomain.com

But this does not seem to do anything


Found the answer.

vi /etc/postfix/main.cf


smtp_generic_maps = hash:/etc/postfix/generic

Then open the following file

vi /etc/postfix/generic

Add the following

app@domain.com app@newdomain.com

Postmap the file

postmap /etc/postfix/generic

Now restart or reload postfix to apply the changes to main.cf

service postfix restart

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.