Score:1

Postfix relay server - replace From address to strip out hostname

sy flag
Kim

Looking to have a postfix relay server that takes email from various users & servers [email protected] and rewrite the header to carry just the [email protected] [email protected]

Easy enough to config the relay server to do this with email that originates from within, but I need it to do this to email that is being relay'd through the relay host.

The usernames will vary greatly and I just don't know all of them, the hostnames will vary, but coming out of the relay server I would like the original "From" username to stay the same with just the domain (stripping out the hostname).

Would like emails relayed through the server changed

From:  [email protected]
To:   [email protected]


main.cf:
compatibility_level = 2
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = ..com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks = 172.0.0.0/8, 127.0.0.0/8
relayhost = [smtp..com]
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix/samples
readme_directory = /usr/share/doc/postfix/README_FILES
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.key
smtpd_tls_security_level = may
smtp_tls_CApath = /etc/pki/tls/certs
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_tls_security_level = may
meta_directory = /etc/postfix
shlib_directory = /usr/lib64/postfix
smtpd_recipient_restrictions =
        permit_mynetworks,
        reject_non_fqdn_recipient,
        reject_unauth_destination
transport_maps = hash:/etc/postfix/transport
sender_canonical_maps =  regexp:/etc/postfix/sender_canonical


sender_canonical file - 
/^(.*@).*$/     ${1}mydomain.com
anx avatar
fr flag
anx
What have you tried so far and why is that not solving your problem? (at first glance this does not sound like your requirements go beyond what postfix `canonical` mappings allow you to do)
Nikita Kipriyanov avatar
za flag
This has a direct answer answer in the Postfix manual.
Zareh Kasparian avatar
us flag
at least share your configuration to have it corrected.
sy flag
Kim
I was able to get everything changed to the same from address using header_checks : main.cf - header_checks = regexp:/etc/postfix/header_checks and the header_checks file - /From:.*/ REPLACE From: [email protected] ..... But would like the original senders name preserved
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.