Hi all
I have a client that deals a lot with a global courier company, that shall remain nameless. This company sends my client emails from a non-resolvable address which means that the SME server rejects them, & rightly so. I don't want to globally turn this feature off so I have come up with a hack/kuldge.
qpsmtpd is designed to use plugins to enhance & extend its basic functionality, the 'Require Resolvable from Host' feature is implemented as one of these plugins; the plugins are stored in /usr/share/qpsmtpd/plugins.
I had a dig through the plugin code & it seemed that the best section for a hack/kludge was the check_dns subroutine:
sub check_dns {
my ($self, $host) = @_;
my @host_answers;
# for stuff where we can't even parse a hostname out of the address
return 0 unless $host;
return 1 if $host =~ m/^\[(\d{1,3}\.){3}\d{1,3}\]$/;
## Kludge for Courier
return 1 if $host = /smtpex/;
## End Kludge
my $res = new Net::DNS::Resolver(dnsrch => 0);
$res->tcp_timeout(30);
$res->udp_timeout(30);
my @mx = mx($res, $host);
foreach my $mx (@mx) {
# if any MX is valid, then we consider the domain
# resolvable
return 1 if mx_valid($self, $mx->exchange, $host);
}
# if there are MX records, and we got here,
# then none of them are valid
return 0 if (@mx > 0);
my $query = $res->search($host);
if ($query) {
foreach my $rrA ($query->answer) {
push(@host_answers, $rrA);
}
}
if ($has_ipv6) {
my $query = $res->search($host, 'AAAA');
if ($query) {
foreach my $rrAAAA ($query->answer) {
push(@host_answers, $rrAAAA);
}
}
}
if (@host_answers) {
foreach my $rr (@host_answers) {
return is_valid($rr->address) if $rr->type eq "A" or $rr->type eq "AAAA";
return mx_valid($self, $rr->exchange, $host) if $rr->type eq "MX";
}
}
else {
$self->log(LOGWARN, "$$ query for $host failed: ", $res->errorstring)
unless $res->errorstring eq "NXDOMAIN";
}
return 0;
}
If you read through the code you'll see my kludge in Orange.
The bad mail host, as identified in the email headers, uses the name smtpex so this is what I checked for, & then I set the return value for $host to 1 if this string is found as per the logic of the module itself.
It's basic but works, prob a lot of better ways to do it but this works for me, feel free to recommend & critique.
Remember to restart qpsmtpd if you make a change like this.
Obviously this change will get trashed if the file is upgraded by a new version of qpsmtpd so document.
For me this is intended to be a temporary fix until I can persuade the muppets in the IT dept that something needs fixing at their end.
Cheers