Skip to content

Enabling SpamExperts for domain removes MX entries from subdomains #242

@lucasRolff

Description

@lucasRolff

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions