Secondary Mail Servers breaks config file

After adding server to Webmin Servers Index and enabling Secondary Mail Servers while creating new domain, cannot access Postifx on Secondary server

Error while checking current Postfix configuration. Please manually fix Postfix configuration.
postfix: warning: "==" or "!="" or "<"" or "<="" or ">="" or ">" expected at: "...$compatibility_level}>>>, <, {2}, ?, {$mydes"
postfix: fatal: dictionary mail_dict: macro processing error

On the end of /etc/postfix/main.cf is added: relay_domains = ${{$compatibility_level}, <, {2}, ?, {$mydestination}, :, {}}, example.com

Status: 
Active

Comments

moskit's picture
Submitted by moskit on Fri, 11/18/2016 - 17:37 Pro Licensee

This happens only when this is 1st domain

Howdy -- hmm, can you paste in the contents of your /etc/postfix/main.cf file on that server? That would help us understand what isn't working there. Thanks!

I am having the same issue. I have followed the instructions to create a relay at https://www.virtualmin.com/documentation/id%2Cmail_relaying_with_virtualmin - when I enable the relay on the my first domain I get the same error.

Error while checking current Postfix configuration. Please manually fix Postfix configuration.
postfix: warning: "==" or "!="" or "<"" or "<="" or ">="" or ">" expected at: "...$compatibility_level}>>>, <, {2}, ?, {$mydes"
postfix: fatal: dictionary mail_dict: macro processing error

Here is the /etc/postfix/main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = alpha.nickschick.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, alpha.nickschick.com, localhost.nickschick.com, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination check_policy_service inet:127.0.0.1:10023
smtp_tls_security_level = may
allow_percent_hack = no
transport_maps = hash:/etc/postfix/transport
relay_domains = ${{$compatibility_level}, <, {2}, ?, {$mydestination}, :, {}}, example.com

I have removed the last line to return function to virtualmin and to start postfix again. Any help would be great

What I would suggest, is to make the last line read:

relay_domains = example.com

The rest of that line shouldn't be necessary.

Thanks andreychek this solution fixes the issue and the relay seems to work properly. The problem I have now is that if you enable the feature "Relay mail for domain?" for the virtual host it generates this automatically so each time I would need to create a new domain that has an external mail server this becomes an issue. Maybe there is a long-term solution for this?

UPDATE - Actually it creates the proper relay on all domains now -- example realy_domain = (adjusted domain.com), new.domain.com, domain2.com ...etc

andreychek's answer worked