Need Help With Issues Using Postfix Generic Rewrite


(Urbnsr) #1

I have been following along with this Wiki: https://wiki.freepbx.org/display/PPS/Setup+Postfix+Manually to send messages out into the real world. I still can’t get it to rewrite the FROM address. In my Postfix generic file I have different variations:

root realaccount@realdomain.com
root@localhost realaccount@realdomain.com
root@localhost.localdomain realaccount@realdomain.com
root@freepbx realaccount@realdomain.com
root@freepbx.localdomain realaccount@realdomain.com
asterisk realaccount@realdomain.com
asterisk@localhost realaccount@realdomain.com
asterisk@localhost.localdomain realaccount@realdomain.com
asterisk@freepbx realaccount@realdomain.com
asterisk@freepbx.localdomain realaccount@realdomain.com
asterisk@freepbx.localhost.localdomain realaccount@realdomain.com
vm@asterisk realaccount@realdomain.com
fax@freepbx.pbx realaccount@realdomain.com

After editing generic, I run postmap /etc/postfix/generic and restart Postfix. After sending a test email from the CL using mail from the asterisk user, maillog indicates a failure and that the FROM address is: asterisk@freepbx.localdomain. I also have smtp_generic_maps = hash:/etc/postfix/generic at the end of my main.cf file.

If I edit generic to only have the line:

@freepbx.localdomain @realdomain.com

…then I can see in maillog that the FROM address is: asterisk@realdomain.com. This fails also since I don’t have an outside email account named “asterisk”, but indicates to me that the generic rewriting is working somewhat. I also have the same problem emailing incoming faxes even though I have the fax address rewrite in the generic file.

What the heck am I missing?


(Dave Burgess) #2

Are you escaping the @ signs? Seems to me PostFix is particular about that sometimes.


(Urbnsr) #3

I am not. I will try it. Although I don’t remember seeing anything about it on Postfix online docs, either.


(Dave Burgess) #4

There are two places where not escaping the @ can mess with you. I think PostFix is usually pretty good about it, but remember that we are running all of this through a system written in PHP, which is horrific when it comes to working with @ signs.


(Urbnsr) #5

I tried to escape the @ symbol, but no change in testing. The initial testing is from the command line using mail. And, to retest (with and without escaping the @ symbol, only having “@freepbx.localdomain @realdomain.com” in the generic file and postfix attempts to rewrite it using the proper domain name: root@freepbx.localdomain becomes root@realldomain.com and asterisk@freepbx.localdomain becomes asterisk@realldomain.com