Code
- package Listener::Named::OverrideDefaultMXRecords;
- use strict;
- use warnings;
- use iMSCP::EventManager;
- iMSCP::EventManager->getInstance()->register(
- 'afterNamedAddDmnDb',
- sub {
- my ($wrkFile, $data) = @_;
- if ( $data->{'EXTERNAL_MAIL'} eq 'on' ) {
- # Remove default mailservers records
- $$wrkFile =~ s/^(?:\@(?:\s+\d+)?\s+IN\s+MX|[0-9]\s+IN)\s+[^\n]+\n//gm;
- # Add out-of-zone mailservers
- $$wrkFile .= "$data->{'DOMAIN_NAME'}.\tIN\tMX\t$_.\n" for @mailservers;
- 0;
- }
- }
- );
- 1;
sorry for the late response, missed that.