Hello, fellas
I have a couple of servers in a private LAN 10.0.0.0/24.
I've set up one of the servers with Postfix in a effort to relay internal mails to an external SMTP server (of my ISP).
Every server in my LAN runs a variety of test apps (in a lab-like environment) and they send out various mail notifications and reports. Every app's settings for mail sender are (usually) in the form of
<app>@lab.local but it can be anything, really.
My question boils down to how to configure Postfix to perform the following
rewrite in the
SMTP envelope and not header.
<myapp>@<randomlocal.domain> ----> <myapp>.<randomlocal.domain>@mylegitinternetdomain.com
And then relay it to the external ISP SMTP.
Recipients' SMTP envelope and header should not get modified.
I got so far:
/etc/postfix/main.cf
Code:
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
smtpd_helo_required = yes
inet_interfaces = 127.0.0.1, 10.0.0.1
inet_protocols = ipv4
relayhost = [smtp.myisp.com]
myhostname = mail.lab.local
mydomain = lab.local
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks_style = subnet
mynetworks = 127.0.0.0/8, 10.0.0.0/24
append_at_myorigin = no
append_dot_mydomain = no
local_header_rewrite_clients = permit_inet_interfaces, permit_mynetworks, reject
remote_header_rewrite_domain = domain.invalid
masquerade_domains = $mydomain
sender_canonical_classes = envelope_sender
sender_canonical_maps = regexp:/etc/postfix/canonical_maps_sender
/etc/postfix/canonical_maps_sender
Code:
if !/@mylegitinternetdomain\.com/i
/^.*?([^\s<]+?)@([^\s>]+?)>?\s*$/i ${1}.${2}@mylegitinternetdomain.com
endif
My regex seems to be wrong as in my Inbox from the ISP SMTP I get mails from "lab.local"@mylegitinternetdomain.com
Help!!!

What am I missing?
Thank you in advance!