Utility to set route to domain MX

This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
Post Reply
mikedibella
Normal user
Normal user
Posts: 181
Joined: 2016-12-08 02:21

Utility to set route to domain MX

Post by mikedibella » 2019-10-04 00:48

I needed a way to bypass the smart relay for some domains and send mail for these domains directly to the mail exchanger in DNS.

A route in HMS will do this, but the Target SMTP Host must be statically defined. These hostnames change from time-to-time, and I wanted a way to keep the route up-to-date so it behaved more like traditional DNS-based MX delivery for that domain only.

hmsRouteMX.exe was written to update a specified route with the the lowest Preference Mail Exchanger published in DNS for the specified domain.

To use hmsRouteMX.exe, edit the appropriate .reg file for your OS and populate the Nameserver, Username, and Password fields with the DNS server, and credentials to access HMS. Change the Logging level (0-2) if you want more or less verbosity in the event log. Copy hmsRouteMX.exe to your hMailServer\Bin directory and schedule it to run using Task Scheduler, passing the route name as a parameter.

Written in Delphi. Source included. Requires The Indy Project libraries to compile. Freeware under The MIT License.
Attachments
hmsRouteMX.zip
(202.72 KiB) Downloaded 24 times

User avatar
jimimaseye
Moderator
Moderator
Posts: 8250
Joined: 2011-09-08 17:48

Re: Utility to set route to domain MX

Post by jimimaseye » 2019-10-04 09:05

Can you explain what you mean by
mikedibella wrote:
2019-10-04 00:48
IA route in HMS will do this, but the Target SMTP Host must be statically defined. These hostnames change from time-to-time, and I wanted a way to keep the route up-to-date so it behaved more like traditional DNS-based MX delivery for that domain only.
Camb you give an example please to better understand the purpose ?

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

mikedibella
Normal user
Normal user
Posts: 181
Joined: 2016-12-08 02:21

Re: Utility to set route to domain MX

Post by mikedibella » 2019-10-04 23:23

For example, an old MTA, which was the lowest Preference host, is retired, and the old backup MX gets promoted by having the new lowest Preference in DNS. Eventually, another MX is introduced, which might have a different hostname, or a higher Preference.

Or, multiple MX share the same Preference and the ordering of the hosts is round-robin'ed by DNS. Each time hmsRouteDNS.exe is run, a new query is made, resulting in a new MX bubbling-up to the top, so traffic then gets distributed across the hosts as the authority for that domain intended.

Post Reply