Reference: File SmtpRouter.hst


Configuration file "SmtpRouter.hst" contains definitions and rules for sending mails by SMTP in MX mode, e. g. when starting mail transfer by script command "HamSendMailMX".

When sending mails in this MX mode, Hamster tries to detect the mail exchange (MX) servers of the mail recipients and then send the mails directly to the servers found.

Sending mails in MX mode mostly works even without any entries in this file, but it is suggested to at least set a fallback server (see "set fallbackserver" below). This setting makes sure, that the mail is sent out immediately even if no MX servers can be found or none of them accepts the mail.

How to ... deliver mails directly (MX)?


File Format

File "SmtpRouter.hst" is a plain text file, that is divided into sections, where each section may contain multiple command lines to be executed.




All lines in the file are checked from top to down, from the first section found up to the end of the file.

If a command line is preceded with a "=" character and this line is executed, all following lines are ignored.


All lines starting with a "#" character are treated as comments, i. e. such lines are ignored.

Trailing comments in section or command lines are not supported in this file.


Each section starts with a "[...]"-header describing the names of dial-up connections (RAS), for which the following lines should be tested. The patterns within "[...]" follow the same rules as the ones described at "Reference: File Scores.hst".


# these lines will always be used, regardless if it is a
# dial-up connection or a direct connection

# these lines will only be used, if no dial-up connection
# exists, e. g. when directly connected by a router

# these lines will only be used, if the name of the current
# dial-up connection (RAS) contains the string "Provider"


set dnsauto

The "dnsauto" setting determines, if DNS servers should be auto-detected. Valid settings are:

0 don't auto-detect, only use "set dnsserver" setting

1 auto-detect and use found ones as preferred servers

2 auto-detect and use found ones as fallback servers

Values 1 and 2 are the same if no servers are given with "set dnsserver" setting. But if servers are given with "set dnsserver" command, the auto-detected servers are either tried before the given ones (1, preferred) or after the given ones (2, fallback).

Note: Although different techniques are used to detect the DNS servers, it may fail with some Windows versions and/or network infrastructures. If Hamster reports "No DNS server found!" warnings, you have to provide one with "set dnsserver".


set dnsauto 1


set dnsauto 2
set dnsserver

The "dnsserver" setting can be used to set the DNS servers to be used when determining the mail exchange servers (MX records) for the recipient of a mail.

Multiple DNS servers can be given by separating them with whitespace (SPACE or TAB characters). Each server can immediately be followed by a colon (":") and a port number, if it does not run on default port number 53.

If you don't know the DNS servers and auto-detecting them does not work, ask your network administrator or your provider for the DNS servers to use.


set dnsserver ""


set dnsserver
set dnstimeout

The "dnstimeout" setting gives the timeout in milliseconds for querying the DNS server for the mail exchange servers (MX records) of recipient's domain.


set dnstimeout 10000


set dnstimeout 5000
set fallbackserver

The "fallbackserver" setting gives a SMTP server to use, when no MX servers are found for recipient's domain or if none of the found ones accepted the mail for any reason. The given server has to be one of the remote SMTP servers configured in Hamster.


set fallbackserver ""


set fallbackserver
set fallbackserver
set fallbackserver
set limitdns

The "limitdns" setting gives the maximum number of DNS servers to query for MX records. A value of 0 disables this limit.


set limitdns 3


set limitdns 1
set limitmx

The "limitmx" setting gives the maximum number of MX servers to try to send a mail. A value of 0 disables this limit.


set limitmx 3


set limitmx 1

A "use" command can select a specific SMTP server based on recipient's domain. This means, that determining of mail exchange servers is turned off and the mail is directly sent to the given server.

First parameter is the SMTP server to use if patterns match. It has to be one of the remote SMTP servers configured in Hamster.

After the server to use, one or more patterns for recipient's domain follow. The patterns work the same way as the ones described at "Reference: File Scores.hst".


use {\.myprovid\.er$}

Usage examples

Setup fallback server(s)

It's suggested to set a fallback server, that is finally used if sending mails in MX mode fails for any reason:

set fallbackserver

If the mail server is only available for a specific dial-up connection (RAS), just note the fallback server in a separate section containing the name of the dial-up connection:

set fallbackserver

MX servers don't accept mails - use specific server instead

Some providers do not accept mails sent to their MX servers from dial-up accounts or from within their own network. In such cases, the time consuming search for MX servers and any attempt to send them mails is completely useless.

For known providers or domains, that show this problem, it is therefore better to directly send the mails to a specific SMTP server, that is known to accept them (e. g. the mailserver of your provider).

The following is an example, how this could be done with the "use" command:

["T-Online" "TOSW-internal"]
use {t-online\.(de|at|com)$} {t-dialin\.net$} {aol\.com$}

It means: If name of current dial-up connection contains "T-Online" or "TOSW-internal", all mails to "", "", "", "" and "" domains should not be sent to the MX servers of these domains but directly to "".

[ Hamster Playground Documentation]