WordPress Developer & Linux Administrator

Clean up /etc/remotedomains using this one liner

Some times you end up with domain in /etc/remotedomains that really don’t belong there. The mailserver will realize this but because they are in that file the MTA will not except mail for that domain. This quick little one liner can be run from the command line and will help you remove the domains from /etc/remotedomains that probably don’t belong there.

for i in `sed -n 's/.*lowest numbered MX record points to local host: \([^[:space:]]\{1,\}\).*/\1/p' /var/log/exim_mainlog | sort | uniq`; do sed "/$i/d" -i /etc/remotedomains; done

What this script does is look through the exim logs looking for errors about a domains lowest MX pointing to local host. If it finds one of these entry’s it strips out the domain and then removes that domain from /etc/remotedomains. Simple enough!

Once done you will need to run /scripts/mailperm

Categories: Commands, cPanel

Comments

Your email address will not be published. Required fields are marked *