Postfix sender rewriting

Started by putt1ck, October 02, 2026, 02:11:57 PM

Previous topic - Next topic
We have a scenario where an internal service sends with a domain that needs rewriting to one that the firewall relay can successfully deliver i.e.

mailbox1@internaldomain.net needs rewriting to mailbox1@correctdomain.com

Our initial research suggested that the Postfix plugin could achieve this with "Sender Canonical Rewriting" but found little documentation on how to correctly complete the fields. Posts elsewhere on this forum suggested we should format the original sender (entered into "Rewrite From") like this:

/mailbox1@internaldomain.net/i

and then the replacement address (entered into "Rewrite To") simply as:

mailbox1@correctdomain.com

However configured like this the sender address is not rewritten and the mail gets relayed with the original "From:" address and the headers do not contain the replacement address anywhere.

Is there any additional documentation on how to achieve the rewrite correctly?

NB the only entry in the logs referencing "canonical" is this: warning: regexp map /usr/local/etc/postfix/sendercanonical, line 1: ignoring unrecognized request but it is from a week ago, not repeated on subsequent service restarts nor when mail flows

All suggestions welcome!

Regards

Chris

October 02, 2026, 09:40:30 PM #1 Last Edit: October 02, 2026, 11:10:48 PM by nero355
I would start reading official documentation for this kind of stuff : https://www.postfix.org/ADDRESS_REWRITING_README.html

Editing .conf files directly shouldn't be a big deal when using OPNsense AFAIK ?!
/EDIT : I was wrong! See below !!

Also this : https://unix.stackexchange.com/a/726317
Seems to match what I know about Sendmail from a long time ago and seems to apply to Postfix too ?! :)
Weird guy who likes everything Linux and *BSD on PC/Laptop/Tablet/Mobile and funny little ARM based boards :)

Quote from: nero355 on October 02, 2026, 09:40:30 PMEditing .conf files directly shouldn't be a big deal when using OPNsense AFAIK ?!

It definitely would. Your config file changes will be overwritten at every reboot. Unless the plugin in question provides e.g. a specific directory for custom configuration. But in general *all configuration* is regenerated from scratch from the config.xml at every reboot.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Quote from: Patrick M. Hausen on October 02, 2026, 10:54:51 PM
Quote from: nero355 on October 02, 2026, 09:40:30 PMEditing .conf files directly shouldn't be a big deal when using OPNsense AFAIK ?!
It definitely would. Your config file changes will be overwritten at every reboot.

Unless the plugin in question provides e.g. a specific directory for custom configuration.
But in general *all configuration* is regenerated from scratch from the config.xml at every reboot.
Hmm... OK. Good to know!

But how about adding .conf files to /etc/postfix/ or /usr/local/etc/postfix or where the main .conf is located anyway ?!

Postfix is the default MTA and not a plug-in : Right ?
Weird guy who likes everything Linux and *BSD on PC/Laptop/Tablet/Mobile and funny little ARM based boards :)

Today at 02:42:59 AM #4 Last Edit: Today at 02:53:57 AM by lmoore
Quote from: nero355 on October 02, 2026, 11:09:49 PMPostfix is the default MTA and not a plug-in : Right ?

It doesn't appear that mail is installed in OPNsense by default, at least not on mine. There is nothing in /etc/mail and no sendmail program.

Quote from: nero355 on October 02, 2026, 11:09:49 PMBut how about adding .conf files

I have done this with Unbound - after reading the documentation. Your mileage may vary for other services, depending on how OPNsense configures them. However, it's best they are managed using an applicable plug-in.

[Edit] Of course, such custom settings wont be included in a back-up.

OPNsense Web GUI for Unbound lets me know there is a configuration which could possibly overwrite settings in the Web GUI.


Responses so far suggest nobody has this working via the plugin. While we're comfortable making Postfix work via conf it would seem that shouldn't be using a plugin on the firewall and we should have a separate VM to act as the relay for mail. Just to be clear what within the conf would be overwritten by updates to the firewall/plugin and why on reboot?