Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling SpamExperts for domain removes MX entries from subdomains #242

Open
lucasRolff opened this issue Sep 1, 2020 · 0 comments
Open

Comments

@lucasRolff
Copy link

Version information

Latest

Steps to replicate

  1. Have a domain such as domain.com with MX entry
  2. Have a subdomain such as feedback.domain.com with another MX entry
  3. Enable SpamExperts for domain.com

Actual result

MX entries for feedback.domain.com gets cleared out

Expected result

Removing MX entries should be an exact match, not all MX entries for domain.com zone

Other notes

SpamExperts module uses listmxs function ( https://documentation.cpanel.net/display/DD/WHM+API+1+Functions+-+listmxs ) , which will return MX entries for the domain including subdomains.

That in itself is fine, but you should do an exact match for the domain when removing MX entries.

In

private function removeMXRecords($domain)
{
$this->_logger->debug("Removing MX records for '{$domain}'");
$records = $this->getMxRecords($domain);
// Reorder list so the highest line is handled first, because line numbers *will* change
$this->_logger->debug("MX sort before:" . serialize($records));
$records = array_sort($records, 'Line', SORT_DESC); // Sort by highest number first
$this->_logger->debug("MX sort after:" . serialize($records));
if (is_array($records)) {
// Remove all found MX records.
foreach ($records as $record) {
$this->_logger->debug("Removing record for {$domain} (Line: {$record['Line']})");
$this->removeDNSRecord($domain, $record['Line']);
}
}
return true;
}
you simply loop over every matched entry and removes it, even for subdomains.

Alternatively you can implement UAPI where it does actual filtering on the exact domain in https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Email%3A%3Alist_mxs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant