In order to restrict the delivery of incoming messages in cPanel/WHM to the servers of EuropeanMX, please follow the steps below.
If the MX records (mx1.europeanmx.eu, mx2.europeanmx.eu, mx3.europeanmx.eu, mx4.europeanmx.eu) for the domain are correctly specified in the DNS system, the following settings will result in
If the receiving domain does not use our MX records, then it is assumed that the domain does not use the filter and messages delivered directly to your mail server for that domain will be accepted.
Connect to the WHM server via SSH.
Create a new file /opt/setest
with the following content:
#!/bin/bash
host -t MX $1 | sort -n -k1 | cut -d ' ' -f 7 | sed -e 's/\.$//' | xargs | sed -e 's/ /:/g' | tr -d '\n'
Save this file.
Create a new file /opt/setestptr
with the following content:
#!/bin/bash
host -t PTR $1 | cut -d ' ' -f5 | sed 's/\.$//g' | tr -d '\n'
Save this file.
Open the Exim Configuration Editor and activate the advanced mode. Now search for custom_begin_recp_verify
.
Now add the following content:
######################################################################################
## Start EuropeanMX verification
defer
!condition = ${if match_domain{${run {/opt/setestptr $sender_host_address}}}{*.antispamcloud.com}}
set acl_m_mx_records = ${run {/opt/setest $domain}}
condition = ${if eq{$acl_m_mx_records}{mx1.europeanmx.eu:mx2.europeanmx.eu:mx3.europeanmx.eu:mx4.europeanmx.eu}}
message = Please deliver mail to the address specified in the MX records for this domain.
## End EuropeanMX verification
#####################################################################
Save the settings.