How to script /etc/mailhelo to always match reverse DNS
Sometimes when using the option "Send mail from account's dedicated IP address" option in WHM "Home "Service Configuration "Exim Configuration Manager" ( . Using that method, you can be very precise about exactly which IP addresses are used for sending email from which domains and what those IP addresses should use for HELO. However, this method requires a lot of administrative overhead, as all of these settings must be manually configured and updated.
For some administrators, it would be easiest to have /etc/mailhelo automatically managed, but to ensure that the HELO used will always match what is in the PTR record for the IP address. Fortunately, when "Send mail from account's dedicated IP address" is used so is /etc/mailhelo - only it is written automatically. This is file is updated any time userdomains data changes on the server (add a domain, new account, etc) with the /scripts/updateuserdomains script.
I have written a postupdateuserdomains hook script ( > /etc/rdns
fi
# Stash our output in a variable to dump back into /etc/mailhelo later
OUTPUT+="$DOMAIN: $RDNS\n"
# End of while loop, command substitution used to feed it.
done < <(awk -F":" '{print $1}' /etc/mailhelo)
# Write the new /etc/mailhelo
echo -e "$OUTPUT" > /etc/mailhelo
Be sure it has the executable bit set:
That's it. If you'd like to see this kind of functionality as a feature in the cPanel/WHM product, please add your votes and comments here: [url=http://features.cpanel.net/responses/an-option-to-use-actual-reverse-dns-resolution-as-helo-for-outbound-email]An option to use actual reverse DNS resolution as HELO for outbound email. | cPanel Feature Requests Also, please be aware that this script is not an official or supported workaround. cPanel will not provide support or troubleshooting for this script outside of this forum thread.
Be sure it has the executable bit set:
chmod +x /scripts/postupdateuserdomains
That's it. If you'd like to see this kind of functionality as a feature in the cPanel/WHM product, please add your votes and comments here: [url=http://features.cpanel.net/responses/an-option-to-use-actual-reverse-dns-resolution-as-helo-for-outbound-email]An option to use actual reverse DNS resolution as HELO for outbound email. | cPanel Feature Requests Also, please be aware that this script is not an official or supported workaround. cPanel will not provide support or troubleshooting for this script outside of this forum thread.
-
Nice. Thank you Phil. Have voted, hopefully others will also. 0 -
the script throws errors when using parked domains parked domains show up as subdomains in /etc/mailhelo so the grep around line 21 needs "-m 1" to limit to the first result: #added -m 1, max count 1, aliases show up as subdomains in /etc/mailhelo and grep will return several results causing garbled data: IP=$(grep -m 1 "^$DOMAIN" /etc/mailips | awk '{print $2}')
this cleaned up some garbled results in /etc/rdns and /etc/mailhelo I also corrected on line 12:# Skip ahead if a line in /etc/mailips is blank if [ "$DOMAIN" == "" ] || [ "$DOMAIN" == "no" ] then continue fi
for some reason /etc/mailhelo contains lines with "no" (probably garbled data) this filters it out0
Please sign in to leave a comment.
Comments
2 comments