MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //proc/self/root/scripts.20110531.215904.25158/checkalldomainsmxs
#!/usr/bin/perl
# cpanel - checkalldomainsmxs                     Copyright(c) 2010 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

BEGIN { unshift @INC, '/usr/local/cpanel'; }

use Cpanel::Usage                   ();
use Cpanel::Config::LoadUserDomains ();
use Cpanel::SafeRun::Errors         ();
use Whostmgr::DNS::MX               ();
use Cpanel::Email::MX               ();

my $proceed = 0;
my $remote_check = 0;
my %opts = ( 'yes' => \$proceed );

Cpanel::Usage::wrap_options( \@ARGV, \&usage, \%opts );

if ( !$proceed ) {
    usage();
}

my %USER_DOMAINS;
Cpanel::Config::LoadUserDomains::loaduserdomains( \%USER_DOMAINS, 1 );

foreach my $domain ( sort keys %USER_DOMAINS ) {
    next if ( $domain =~ m/^\*/ );
    my %entries = Whostmgr::DNS::MX::fetchmx($domain);
    print "Checking and setting $domain ....";
    my $checkmx = Whostmgr::DNS::MX::checkmx( $domain, $entries{'entries'}, 0, 1 );
    if ( ref $checkmx eq 'HASH' ) {
        my($set,$status,$method,$warnings) = Cpanel::Email::MX::get_mxcheck_messages($domain,$checkmx);
        print (!$set ? join("\n",@$warnings) : ($status . ($method ? ": $method" : '') . (@$warnings ? ' : ' .  join("\n",@$warnings) : ''))) . "<br />";
    }
    print "....Done\n";
}

# Argument specified to not run updateuserdomains in Whostmgr::DNS::MX::checkmx
Cpanel::SafeRun::Errors::saferunallerrors('/scripts/updateuserdomains');
print "\n";

sub usage {

    print <<"EOM";
This script will check each MX entry for every domain configured on this machine. 

The MX record will be determined from the zone file associated with this server, 
not from a remote query of the DNS record. If you are using and editing the zone
file on a server not associated with this server through a DNS cluster configuration,
then this utility will configure your email settings incorrectly. 

This utility updates the following files which alter the local delivery and sending
methods of email:

/etc/localdomains
/etc/remotedomains
/etc/secondarymx

As a safety precaution you must run this utility with the argument "--yes" to proceed.
    example: 
        $0 --yes
EOM
    exit;
}