Skip to content

Need to create generics table to catch bare "root" destinations

This is probably a corner case, which is why it hasn't been an issue before. However I think it's worth catching and should be simple enough.

When sending mail from (ex.) 3cx.phone.celadonsystems.com, things work fine if I fully specify the destination address (ex. mail -s test chrome@real-time.com). However, if I send mail to just root (ex. mail -s test root) it attempts to deliver the mail to root@3cx.phone.celadonsystems.com. This of course fails when it hits the relay server (relay.dmz.celadonsystems.com in the example below) because that server doesn't know how to deliver that address. So we need a generics table to rewrite destinations (in the example below, smtp_generic_maps = hash:/etc/postfix/rewrite_destination_addresses

rte@3cx:~$ cat /etc/postfix/main.cf
smtpd_banner = $myhostname ESMTP $mail_name 
biff = no
append_dot_mydomain = no
readme_directory = no

# http://www.postfix.org/BASIC_CONFIGURATION_README.html#myorigin
myhostname = celadonsystems.com
myorigin = $myhostname

# don't accept any mail locally
mydestination = 

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

# Need to rewrite outbound mail so it goes to admin@celadonsystems.com
# instead of (ex.) 'root' which would try to go to root@3cx.phone.celadonsystems.com, 
# and thus be rejected as undeliverable in O365
smtp_generic_maps = hash:/etc/postfix/rewrite_destination_addresses


relayhost = [relay.dmz.celadonsystems.com]
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all
compatibility_level = 0
rte@3cx:~$ cat /etc/postfix/rewrite_destination_addresses
# we only want to catch mail which is bound for localhost
@3cx.phone.celadonsystems.com   admin@celadonsystems.com
@localhost                      admin@celadonsystems.com
@localhost.localdomain          admin@celadonsystems.com

Of course we also need to do a "postmap /etc/postfix/rewrite_destination_addresses" (it will work with the full path specified, even if the working directory isn't set to ex. /etc/postfix/).

Other noteworthy settings in the example are below, but those will be tracked in another issue.

# http://www.postfix.org/BASIC_CONFIGURATION_README.html#myorigin
myhostname = celadonsystems.com
myorigin = $myhostname

# don't accept any mail locally
mydestination = 
Edited by Carl